ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Can a sheet be named automatically based off the value of a cell? (https://www.excelbanter.com/excel-worksheet-functions/142962-can-sheet-named-automatically-based-off-value-cell.html)

ktun

Can a sheet be named automatically based off the value of a cell?
 


Gord Dibben

Can a sheet be named automatically based off the value of a cell?
 
Yes

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Me.Name = Range("A1").Value
End If
End Sub

This is event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that sheet module.

Note: this code will not be triggered by a calculated vale in A1, just an
entered value.

If you want the name change based on a calculated value use this instead.

Private Sub Worksheet_Calculate()
Me.Name = Range("A1").Value
End Sub

No error checking in either set of code.


Gord Dibben MS Excel MVP

On Wed, 16 May 2007 07:39:00 -0700, ktun wrote:




All times are GMT +1. The time now is 03:41 AM.

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