Forum Discussion
Worksheet tabs to include date from a cell
You can do this with a simple VBA macro, since sheet names can’t be linked directly to cells. Add this code to the relevant sheets in the VBA editor (Alt+F11):
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("H1")) Is Nothing Then
Dim dt As String
dt = Format(Me.Range("H1").Value, "dd-mmm-yyyy")
Select Case Me.CodeName
Case "Sheet1" ' adjust to your sheet code name
Me.Name = "AR - as of " & dt
Case "Sheet3"
Me.Name = "AP - as of " & dt
End Select
End If
End Sub
Whenever H1 changes, the tab name updates automatically.
https://learn.microsoft.com/en-us/office/vba/excel/concepts/workbooks-and-worksheets/name-a-worksheet-by-using-a-cell-value