我在下面的这个VBA可以在我的工作簿中工作,它可以获取信息并在工作簿中填充工作表。问题是工作簿变得越来越大而且速度慢,崩溃。我想使用VBA将信息填充到不同的工作簿中。知道怎么做吗?
Sub AutoAddSheet()
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Print Sheets").Range("L1")
Set MyRange = Range("SummTabNames")
'Set MyRange = Range(MyRange, MyRange.End(xlDown))
Dim msg As String
On Error GoTo handler
msg = "Error: You are trying to create a sheet that already exists. You cannot have duplicate sheets. Please clear duplicate sheets to continue."
For Each MyCell In MyRange
Sheets("CCDetailTemplate").Copy after:=Sheets(Sheets.Count) 'Create a new worksheet as a copy of Sheet number 9 in this example
Sheets(Sheets.Count).Name = MyCell.Value 'Renames the new worksheets
Next MyCell
'On Error GoTo ErrorHandler
'ErrorHandler:
'if (typeof err.Number is (9)
Sheets("acr summary").Select
Exit Sub
handler:
MsgBox (msg)
End Sub