jrobin5881
Technical User
I've been wrestling with this code for awhile today and I can't figure out why the loop runs once and then bombs out. Here's what I'm trying to do, select two sheets in the current workbook, copy and paste into a new workbook and save it based on the name in the Sheets(i)tab. It runs one iteration fine and then on the next one it bombs out on this line: Sheets(Array(i, j)).Select
The debug message reads:"Runtime error 1004. Select method of sheets class failed" Code is below
Sub looper()
j = 11
For i = 2 To 7
Sheets(Array(i, j)).Select
Sheets(i).Activate
strName = ActiveSheet.Name
Sheets(Array(i, j)).Copy
ActiveWorkbook.SaveAs "T:\OPS\OPSDEL\DELIVERY\Oppty\Final_Report\" & strName & "WK_27"
DisplayAlerts = False
ActiveWorkbook.Close
DisplayAlerts = True
Windows("OpportunityTelecomWeek_FinalReport_Master").Activate
j = j + 1
Next
End Sub
The debug message reads:"Runtime error 1004. Select method of sheets class failed" Code is below
Sub looper()
j = 11
For i = 2 To 7
Sheets(Array(i, j)).Select
Sheets(i).Activate
strName = ActiveSheet.Name
Sheets(Array(i, j)).Copy
ActiveWorkbook.SaveAs "T:\OPS\OPSDEL\DELIVERY\Oppty\Final_Report\" & strName & "WK_27"
DisplayAlerts = False
ActiveWorkbook.Close
DisplayAlerts = True
Windows("OpportunityTelecomWeek_FinalReport_Master").Activate
j = j + 1
Next
End Sub