【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《简易VBA代码》,欢迎阅读!
合并工作表
Sub Macro1()
Dim intRows As Integer
Dim intCols As Integer
For i = 2 To Sheets.Count
intRows = Sheets(i).UsedRange.Rows.Count
intCols = Sheets(i).UsedRange.Columns.Count
For j = 1 To intRows
Sheet1.Cells(j + 20 * (i - 2), 1) = Sheets(i).Name
For k = 1 To intCols
Sheet1.Cells(20 * (i - 2) + j, k + 1) = Sheets(i).Cells(j, k)
Next Next Next
End Sub
Sub 拆分多工作表() '将工作薄按工作表拆分成多个工作薄
Dim PATH As String
PATH = Application.ActiveWorkbook.PATH
Dim sht As Worksheet
Application.ScreenUpdating = False
For Each sht In Sheets
sht.Copy
ActiveWorkbook.SaveAs PATH & "\" & sht.Name & ".xls" '(工作表名称为文件名)
ActiveWorkbook.Close Next
Application.ScreenUpdating = True
End Sub
本文来源:https://www.wddqxz.cn/0a868313c950ad02de80d4d8d15abe23482f03d1.html