ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sheet tab name (https://www.excelbanter.com/excel-worksheet-functions/7956-sheet-tab-name.html)

~Jeff~

Sheet tab name
 
Is there a way to set the spreadsheet up so that the value in cell A4
appears as the sheet tab name?

--
~Jeff~
[Microsoft Windows XP Pro,Office 2000]



Chip Pearson

Only with VBA code.

Sub AAA()
ActiveSheet.Name = ActiveSheet.Range("A4").Text
End Sub

or you can use an event procedure to automate this. In the code
module for the worksheet in question, use

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Then
Me.Name = Target.Text
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"~Jeff~" wrote in message
...
Is there a way to set the spreadsheet up so that the value in
cell A4
appears as the sheet tab name?

--
~Jeff~
[Microsoft Windows XP Pro,Office 2000]





Frank Kabel

Hi
you have to use VBA for this. e.g. put the following code in your workshete
module

Private Sub Worksheet_Change(ByVal Target As Range)
if target.address="$A$4" then
on error resume next
application.enableevents=false
me.name=target.value
application.enableevents=true
end if
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

~Jeff~ wrote:
Is there a way to set the spreadsheet up so that the value in cell A4
appears as the sheet tab name?




Andy Brown

"~Jeff~" wrote in message
...
Is there a way to set the spreadsheet up so that ...


Yes, with event code (if you mean "so that the sheet name becomes whatever's
in A4" & not the other way around).

Rightclick the sheet tab, click "View Code" ; then paste the following into
the worksheet module.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$4" Then Exit Sub
On Error GoTo 100:
ActiveSheet.Name = Target
Exit Sub
100:
MsgBox "Cannot rename sheet."
End Sub




All times are GMT +1. The time now is 10:11 AM.

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