![]() |
Automatically Update Sheet Names
Hi All,
Does anybody know how I can automatically name the sheets of a workbook based on the contents of a cell. For example, if I have the word January in Cell A:1, I would like the Sheet name to be January. If I change January to May, I would like the sheet to automatically update and rename itself to May. Any ideas? Thanks, Steve |
Automatically Update Sheet Names
Hi Steve,
Try: '================== Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range Set rng = Range("A1") On Error Resume Next If Not Intersect(Target, rng) Is Nothing Then If Not IsEmpty(rng) Then Sheet2.Name = rng.Value End If End If On Error GoTo 0 End Sub '<<================== --- Regards, Norman "Steve" wrote in message news:pIj7f.298576$tl2.109713@pd7tw3no... Hi All, Does anybody know how I can automatically name the sheets of a workbook based on the contents of a cell. For example, if I have the word January in Cell A:1, I would like the Sheet name to be January. If I change January to May, I would like the sheet to automatically update and rename itself to May. Any ideas? Thanks, Steve |
Automatically Update Sheet Names
If you want it for all sheets in a book, try
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) Const WS_RANGE As String = "A1" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Sh.Range(WS_RANGE)) Is Nothing Then With Target If .Value < "" Then Sh.Name = .Value End If End With End If ws_exit: Application.EnableEvents = True End Sub 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Steve" wrote in message news:pIj7f.298576$tl2.109713@pd7tw3no... Hi All, Does anybody know how I can automatically name the sheets of a workbook based on the contents of a cell. For example, if I have the word January in Cell A:1, I would like the Sheet name to be January. If I change January to May, I would like the sheet to automatically update and rename itself to May. Any ideas? Thanks, Steve |
Automatically Update Sheet Names
Thanks guy's,
The code works just great! Steve *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 12:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com