I can offer a more "general" and possibly faster answer, just for the sake of using it. Just keep in mind that this is from VBA and will require minor changes to run in the same environment as your question.
Sub sheetCopier() Dim destSht As Object, srcSht As Object, NewShts As Long, shtCnt As Long Set srcSht = ThisWorkbook.Sheets(2) For NewShts = 1 To 5 shtCnt = ThisWorkbook.Sheets.Count srcSht.Copy after:=ThisWorkbook.Sheets(shtCnt) Set destSht = ThisWorkbook.Sheets(shtCnt + 1) destSht.Name = "New Sht" & Format(NewShts, "00") Next Set srcSht = Nothing Set destSht = Nothing End Sub
obviously that might interest you:
shtCnt = ThisWorkbook.Sheets.Count srcSht.Copy after:=ThisWorkbook.Sheets(shtCnt) Set destSht = ThisWorkbook.Sheets(shtCnt + 1) destSht.Name = "New Sht" & Format(NewShts, "00")
and the rest just start the demonstration.
you can do things with even less code, but it's not so nice:
thisworkbook.sheets(2).Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = "New Sht" & Format(NewShts, "00")
therefore, I assume (but cannot confirm) that your code can be written as:
for ($i = 1; $i -le 3; $i++) { $wb.Worksheets(2).Copy(,$wb.Worksheets($wb.Worksheets.count)) $name = "Summary$i" $wb.Worksheets($wb.Worksheets.count).Name = $name }
just note that the copy syntax is: .copy ([before], [after]) with options before and after. In vba, the following methods: .copy after:=ASheetObject or .copy ,aSheetObject
amuses
Apostolos55
source share