Hi,
Using Excel 2010. I have the below macro to create new sheets. I want my MTH which is part of each sheet name to have a "0" in front if it is single digit.
MTH increases by 1 with each iteration.
If MTH <10, it should have a 0 in front.
IF MTH>=10, no need to have a 0 in front.
Thank you.
Using Excel 2010. I have the below macro to create new sheets. I want my MTH which is part of each sheet name to have a "0" in front if it is single digit.
MTH increases by 1 with each iteration.
If MTH <10, it should have a 0 in front.
IF MTH>=10, no need to have a 0 in front.
Code:
Sub GenSheets1()
Dim i As Integer
Dim Mth As String
Mth = "05"
Application.ScreenUpdating = False
For i = 1 To 3
Worksheets("Sheet1").Copy after:=Sheets(Sheets.Count)
Mth = Mth + 1
ActiveSheet.Name = "Book" & Mth
Next
Application.ScreenUpdating = True
End Sub
Thank you.