MrFlooglebinder
New Member
- Joined
- Feb 19, 2015
- Messages
- 3
Hi Guys,
I am hoping someone can pin point what I am doing wrong here.
I am trying to auto generate 31 sheets, each sheet is named numerically from 1-31
My issue is that every 10th sheet gives me a number that is not correct.
The sheets end up getting labeled like the following. (sheets separated by commas)
1,2,3,4,5,6,7,8,9,143043,11,12,13,14,15,16,17,18,19,243043,21,21....etc
Note: before I run the code I already have a sheet labeled "1" which has a template on it that is copied to each new sheet that gets generated.
I am hoping someone can pin point what I am doing wrong here.
I am trying to auto generate 31 sheets, each sheet is named numerically from 1-31
My issue is that every 10th sheet gives me a number that is not correct.
The sheets end up getting labeled like the following. (sheets separated by commas)
1,2,3,4,5,6,7,8,9,143043,11,12,13,14,15,16,17,18,19,243043,21,21....etc
Note: before I run the code I already have a sheet labeled "1" which has a template on it that is copied to each new sheet that gets generated.
Code:
Sub Macro1()
Dim sheetname As String
sheetname = 2
For i = 2 To 31
Sheets("1").Select
Cells.Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = WorksheetFunction.Text(Now(), sheetname)
ActiveSheet.Paste
sheetname = sheetname + 1
Next i
Sheets("1").Select
Range("V3").Select
End Sub