I want a copier to copy one sheet multiple times. So I have made a week planning for week 1. And now I want this sheet 51 more times. So the name has to start with a 2 and end with a 52. To make this work for x To y I made the following code:
Sub Copier()
Dim a As Integer
Dim b As Integer
a = InputBox("Enter begin number for making copy's")
b = InputBox("Enter end number for making copy's")
For x = a To b
'Loop to make x number copies.
ActiveWorkbook.ActiveSheet.Copy _
Before:=ActiveWorkbook.Sheets("x")
'The name of every copied sheet is a number.
Next
End Sub
When I execute this, it gives an error : "Error 9 during executing. The subscript is out of range." (I translated it because I have Dutch Excel.)
I don't see what is wrong because this code is copied from the Microsoft page. Has anyone an idea?