DouglasWicker
New Member
- Joined
- Aug 8, 2017
- Messages
- 38
Morning all
I have a workbook of 600+ sheets all named by the date the sheet refers to (in the form 1Jan17).
I am trying to use vba to change the name of the sheets to the dates respective weekday. i.e I need all the dates that were a Monday to have the sheet name "Monday" and not "4Jan16".
I have a list of dates that were mondays, tuesdays etc.
Trying to assign the all the dates in string format to a variable, and then run code to check whether the sheet is called this, if so, change sheetname, if not, test next sheet.
I thought of this code as a guess but not working (this code is just for mondays).
Sub convertabstodates()
Dim Mdate As String
Dim rev As String
Mdate = "4Jan16" & "," & "11Jan16" & "," & "18Jan16" & "," & "25Jan16" & "," & "1Feb16" & "," & "8Feb16" & "," & "15Feb16" & "," & "22Feb16" & "," & "29Feb16" & "," & "7Mar16" & "," & "14Mar16" & "," & "21Mar16" & "," & "28Mar16" & "," & "4Apr16" & "," & "11Apr16" & "," & "18Apr16" & "," & "25Apr16" & "," & "2May16" & "," & "9May16" & "," & "16May16" & "," & "23May16" & "," & "30May16" & "," & "6Jun16" & "," & "13Jun16" & "," & "20Jun16" & "," & "27Jun16" & "," & "4Jul16" & "," & "11Jul16" & "," & "18Jul16" & "," & "25Jul16" & "," & "1Aug16" & "," & "8Aug16" & "," & "15Aug16" & "," & "22Aug16" & "," & "29Aug16" & "," & "5Sep16" & "," & "12Sep16" & "," & "19Sep16" & "," & "26Sep16" & "," & "3Oct16" & "," & "10Oct16" & "," & "17Oct16" & "," & "24Oct16" & "," & "31Oct16" & "," & "7Nov16" & "," & "14Nov16" & "," & "21Nov16" & "," & "28Nov16" & "," & "5Dec16" & "," & "12Dec16" & "," & "19Dec16" & "," & "26Dec16"
If InStr(Mdate, ActiveSheet.Mame) <> 0 Then
ActiveSheet.Name = "Monday"
End If
End Sub
All help appreciated
I have a workbook of 600+ sheets all named by the date the sheet refers to (in the form 1Jan17).
I am trying to use vba to change the name of the sheets to the dates respective weekday. i.e I need all the dates that were a Monday to have the sheet name "Monday" and not "4Jan16".
I have a list of dates that were mondays, tuesdays etc.
Trying to assign the all the dates in string format to a variable, and then run code to check whether the sheet is called this, if so, change sheetname, if not, test next sheet.
I thought of this code as a guess but not working (this code is just for mondays).
Sub convertabstodates()
Dim Mdate As String
Dim rev As String
Mdate = "4Jan16" & "," & "11Jan16" & "," & "18Jan16" & "," & "25Jan16" & "," & "1Feb16" & "," & "8Feb16" & "," & "15Feb16" & "," & "22Feb16" & "," & "29Feb16" & "," & "7Mar16" & "," & "14Mar16" & "," & "21Mar16" & "," & "28Mar16" & "," & "4Apr16" & "," & "11Apr16" & "," & "18Apr16" & "," & "25Apr16" & "," & "2May16" & "," & "9May16" & "," & "16May16" & "," & "23May16" & "," & "30May16" & "," & "6Jun16" & "," & "13Jun16" & "," & "20Jun16" & "," & "27Jun16" & "," & "4Jul16" & "," & "11Jul16" & "," & "18Jul16" & "," & "25Jul16" & "," & "1Aug16" & "," & "8Aug16" & "," & "15Aug16" & "," & "22Aug16" & "," & "29Aug16" & "," & "5Sep16" & "," & "12Sep16" & "," & "19Sep16" & "," & "26Sep16" & "," & "3Oct16" & "," & "10Oct16" & "," & "17Oct16" & "," & "24Oct16" & "," & "31Oct16" & "," & "7Nov16" & "," & "14Nov16" & "," & "21Nov16" & "," & "28Nov16" & "," & "5Dec16" & "," & "12Dec16" & "," & "19Dec16" & "," & "26Dec16"
If InStr(Mdate, ActiveSheet.Mame) <> 0 Then
ActiveSheet.Name = "Monday"
End If
End Sub
All help appreciated