gellis11239
New Member
- Joined
- Dec 23, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi all, i'm sure i'm missing something easy.
I have some code that copies a sheet and renames it in numerical order. (First sheet is "PON 9001") but the way this code is the current way I get PON 91, PON 92 etc. I really need PON 9001, PON 9002....... al the way to PON 9500. I just can't work it out.
Current code is
I have some code that copies a sheet and renames it in numerical order. (First sheet is "PON 9001") but the way this code is the current way I get PON 91, PON 92 etc. I really need PON 9001, PON 9002....... al the way to PON 9500. I just can't work it out.
Current code is
VBA Code:
Sub Create()
Dim I As Long
Dim xNumber As Integer
Dim xName As String
Dim xActiveSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
Set xActiveSheet = ActiveSheet
xNumber = InputBox("Enter number of times to copy the current sheet")
For I = 1 To xNumber
xName = ActiveSheet.Name
xActiveSheet.Copy After:=ActiveWorkbook.Sheets(xName)
ActiveSheet.Name = "PON 9" & I
Next
xActiveSheet.Activate
Application.ScreenUpdating = True
End Sub