Hi,
I have this code that worked in another program but now that I use it in a new one, it converts all the tab names to dates except for the last three ones. The only thing that I changed was the tabs number. The old one was from 11-22 this one is 9-20
The debug highlights this part of the code:
Thank you
I have this code that worked in another program but now that I use it in a new one, it converts all the tab names to dates except for the last three ones. The only thing that I changed was the tabs number. The old one was from 11-22 this one is 9-20
Code:
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("AB2")) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Dim x As Long, y As Long
y = 0
For x = 9 To 20
Sheets(x).Name = "Sheet" & x
Next x
For x = 9 To 20
Sheets(x).Name = Replace(DateAdd("m", y, Range("AB2").Value), "/", "-")
Sheets(x).Name = Left(MonthName(Month(Sheets(x).Name)), 3)
y = y + 1
Next x
Application.ScreenUpdating = True
End Sub
Code:
Sheets(x).Name = Left(MonthName(Month(Sheets(x).Name)), 3)