I have 52 sheets in my workbook, and would like to type in a date in the first sheet, and have the rest of the sheets auto fill for the rest of the year. Any clues
Thanks
I was wanting the sheet name to be the date of the last day of the week, and have the rest of the 52 sheets auto fill for the rest of the year. The workbook is a weekly report kind of thing. Sorry I wasn't clearer.
Mike Case
Lakeland, Florida
This will name the sheet with the date of the following Saturday.
Public Sub RenameSheets()
Dim i As Long
Dim nDate As Date
nDate = Date + 7 - WeekDay(Date) 'Saturday
For i = 1 To Worksheets.Count
Worksheets(i).Name = Format(nDate, "dd-mmm-yyyy")
nDate = nDate + 7
Next i
End Sub
or, if you want to enter the first sheet name manually:
Public Sub RenameSheets()
Dim i As Long
Dim nDate As Date
nDate = CDate(Worksheets(1).Name) + 7
For i = 2 To Worksheets.Count
Worksheets(i).Name = Format(nDate, "dd-mmm-yyyy")
nDate = nDate + 7
Next i
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.