ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Worksheet Name (https://www.excelbanter.com/excel-programming/328936-setting-worksheet-name.html)

Nigel Bennett

Setting Worksheet Name
 
Is there a way for a Worksheet name to be changed the the
value in a particular cell

I would like the value for example in cell C1 to be the
worksheet name


Thanks

Nigel

Nigel

Setting Worksheet Name
 
If the sheet you wish to name is active then use....
ActiveSheet.Name = Range("C1")

If it is called Sheet1 then use....
Worksheets("Sheet1").Name = Range("C1")

If the active sheet is not providing the value from range C1 then use....
Worksheets("Shhet1").Name = Worksheets("Sheet").Range("C1")

NOTE: If C1 is empty you will get an error.


--
Cheers
Nigel



"Nigel Bennett" wrote in message
...
Is there a way for a Worksheet name to be changed the the
value in a particular cell

I would like the value for example in cell C1 to be the
worksheet name


Thanks

Nigel




Gord Dibben

Setting Worksheet Name
 
Nigel

To have the worksheet tab name follow the cell value.......

From Bob Phillips..........

Private Sub Worksheet_Change(ByVal Target As Range)
'autoname the worksheet Tab from value in A5
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A5")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Me.Name = .Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Alternative on a button or shortcut key.

Sub SheetName()
ActiveSheet.Name = Range("A5")
End Sub


Gord Dibben Excel MVP

On Sat, 7 May 2005 09:17:56 -0700, "Nigel Bennett" wrote:

Is there a way for a Worksheet name to be changed the the
value in a particular cell

I would like the value for example in cell C1 to be the
worksheet name


Thanks

Nigel



Gord Dibben

Setting Worksheet Name
 
Nigel

Addendum to my other post.

The Worksheet_Change is sheet event code.

Right-click on the sheet tab and paste the code into that sheet module.


Gord Dibben Excel MVP

On Sat, 7 May 2005 09:17:56 -0700, "Nigel Bennett" wrote:

Is there a way for a Worksheet name to be changed the the
value in a particular cell

I would like the value for example in cell C1 to be the
worksheet name


Thanks

Nigel



Ken Valenti

Setting Worksheet Name
 
You can put your code in the change event of the worksheet.
Still need to catch errors for invalid names

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("C1").Address Then ActiveSheet.Name =
Range("C1").Value
End Sub



"Nigel Bennett" wrote:

Is there a way for a Worksheet name to be changed the the
value in a particular cell

I would like the value for example in cell C1 to be the
worksheet name


Thanks

Nigel



All times are GMT +1. The time now is 09:19 AM.

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