Reputation: 131
I have a piece of code where i don't see where it goes wrong exactly. I have this macro that copies a sheet a certain amount of times and name them "Sheet" + number.
'copies over template to amount of items
For numtimes = 2 To LastRow
ActiveWorkbook.Sheets("sheet").Copy _
After:=ActiveWorkbook.Sheets("Sheet")
'test voor name copy
ActiveSheet.Name = "Sheet" & i
Next
when i run this it copies the sheet only two times. One named "Sheet2"(as it should), but one as "Sheet (2)", and an error that the name is already taken. I don't really see where it goes wrong, or why it half works.
Upvotes: 2
Views: 461
Reputation: 12279
You don't appear to be increasing i
?
Perhaps you could just use numtimes
?
For numtimes = 2 To LastRow
ActiveWorkbook.Sheets("sheet").Copy _
After:=ActiveWorkbook.Sheets("Sheet")
'test voor name copy
ActiveSheet.Name = "Sheet" & numtimes
Next
Upvotes: 3