Changing mulitple tab names
One way:
Public Sub RenameByWeeks()
Dim vResult As Variant
Dim dFirstDate As Double
Dim i As Long
Do
vResult = Application.InputBox( _
Prompt:="Enter year:", _
Type:=1, _
Title:="Rename Worksheets by weeks", _
Default:=Year(Date) + 1)
If vResult = False Then Exit Sub 'user cancelled
Loop Until (vResult 1904) And (vResult <= 9999)
dFirstDate = DateSerial(vResult, 1, 1)
dFirstDate = dFirstDate - WeekDay(dFirstDate) + 1
With ActiveWorkbook.Worksheets
.Item(1).Name = "Jan 1-" & Format(dFirstDate + 6, "d")
For i = 2 To .Count
dFirstDate = dFirstDate + 7
.Item(i).Name = Format(dFirstDate, "mmm d\-") & _
Format(dFirstDate + 6, "d")
Next i
End With
End Sub
In article ,
"RD" wrote:
Is there a way of changing tab names in one or two steps? I have 52 sheets
each one carrying last years names for each week: May 1-7; May 8-15 etc.
Can they be changed in a group to the new dates for 2007-2008: April 30-May
6; May 7-14 etc.?
RD
|