ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Auto Update Sheet Tab (https://www.excelbanter.com/excel-worksheet-functions/26331-auto-update-sheet-tab.html)

Karen

Auto Update Sheet Tab
 
I have a date in cell D1 and (of course) it changes every day. Is there a
way of auto updating the sheet tab name when the date changes in cell D1?

Thank you, Karen

Jason Morin

Right-click on the worksheet tab, select View Code, and paste in the
following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Me.[D1], Target) Is Nothing Then
On Error GoTo InvalidName
Me.Name = Target.Value
Exit Sub
End If
InvalidName:
MsgBox "Invalid sheet name."
End Sub

---
Press ALT+Q to close the VBE.

HTH
Jason
Atlanta, GA


"Karen" wrote:

I have a date in cell D1 and (of course) it changes every day. Is there a
way of auto updating the sheet tab name when the date changes in cell D1?

Thank you, Karen


Karen

Thank you for your help - I pasted the code as you mentioned and the sheet
tab is not changing. I exited the file and reopened it and nothing happened.
Am I doing something wrong?

"Karen" wrote:

I have a date in cell D1 and (of course) it changes every day. Is there a
way of auto updating the sheet tab name when the date changes in cell D1?

Thank you, Karen


Jason Morin

Make sure you select "Enable Macros" upon opening your file. I would also
check Tools Options Security tab and click the "Macro Security" button.
Make sure it is not set to "High."

What I gave was some code I posted recently. I should have tested it before
giving it to you. Replace the code I originally posted with this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Me.[D1], Target) Is Nothing Then
On Error GoTo InvalidName
Me.Name = Format(Target.Value, "mm-dd-yy")
Exit Sub
End If
InvalidName:
MsgBox "Invalid sheet name."
End Sub

---
HTH
Jason
Atlanta, GA




"Karen" wrote:

Thank you for your help - I pasted the code as you mentioned and the sheet
tab is not changing. I exited the file and reopened it and nothing happened.
Am I doing something wrong?

"Karen" wrote:

I have a date in cell D1 and (of course) it changes every day. Is there a
way of auto updating the sheet tab name when the date changes in cell D1?

Thank you, Karen



All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com