Automatic naming of worksheets

A

alifea

I have a cell which automatically calculates the date for the work sheet. Is is possible to have the worksheet tabs automatically change to the same date as is in the cell, such that when I change the date in the associated cell on the first page, that all the tabs update to reflect the newly calculated date in their corresponding cell?

I have been manually renaming each sheet, and while is is not that big a deal, having an automatic function would simplify annual updates.

Thank you for your time.
 
J

J.E. McGimpsey

One way:

Assume dates in cell A1 for each worksheet.

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Dim wkSht As Worksheet
On Error Resume Next
For Each wkSht In Worksheets
With wkSht
If .Range("A1").Text <> .Name Then _
.Name = .Range("A1").Text
End With
Next wkSht
On Error GoTo 0
End Sub

Put this in the ThisWorkbook code module (right-click on the
workbook title bar, choose View Code, paste the following in the
window that opens, then click the XL icon on the toolbar to return
to XL).
 

Ask a Question

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.

Ask a Question

Top