假设你用的工作表是Sheet1,每一行档案记录都要创建一个sheet
Sub Macro1()
'
' Macro1 Macro
Dim I As Integer
Dim Zname As String
Zname = ActiveSheet.UsedRange.Address
For I = 1 To Val(Mid(Zname, InStr(InStr(Zname, ":") + 2, Zname, "$") + 1, 6))
Zname = Format(I)
Rows(Zname & ":" & Zname).Copy
If Not WorksheetExists(Zname) Then
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = Zname
End If
Sheets(Zname).Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Sheet1").Select '假设你用的工作表Sheet1
Next
End Sub
Function WorksheetExists(ByVal SheetName As String) As Boolean
Dim sName As String
On Error GoTo err1
sName = Worksheets(SheetName).Name
WorksheetExists = True
Exit Function
err1:
WorksheetExists = False
End Function
追问根据表中姓名自动创建100个分表,而且分表中格式与总表不同。
要求按总表中相应栏目填入分表。
请提供详细操作方法。