Updating Worksheet Names for Rolling-12 Report
I have 13 worksheets in my workbook. For Sheet2 to Sheet13, I want the sheet
name to reflect its own cell A5. I have code in Sheet1 to accomplish this
task for the subsequent 12 sheets, but currently it only changes the 2nd
worksheet name and I can't figure out why. See below:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As Long
Dim Counter As Long
Let Counter = Worksheets.Count
On Error Resume Next
For i = 2 To Counter
Sheets(i).Name = Cells(5, 1).Value
Next i
On Error GoTo 0
End Sub
How can I get the code to update all 12 worksheet names? Here's some
reference information to see how the names are derived from the target cells:
Sheet1 is named "Settings" and is the only sheet with a fixed name. Because
workbooks are based on a rolling 12 month period, cell B17 is a variable
month field currently set to "January" and B18 is a variable year field
currently set to "2005".
Cell A5 of Sheet1 is =B17&" "&B18
Cell A5 of Sheet2 is ="Settings!B17&" "&Settings!B18"+0
Cell A5 of Sheet3 is =DATEVALUE(Settings!B17&Settings!B18)+32
Cell A5 of Sheet4 is =DATEVALUE(Settings!B17&Settings!B18)+64
Cell A5 of Sheet5 is =DATEVALUE(Settings!B17&Settings!B18)+96
Cell A5 of Sheet6 to Sheet13 is the same, each with a higher multiple of 32
so that it displays the next month in sequence.
Any Ideas on how to make this work?
Thanks,
Damian Carrillo
|