#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Worksheet name

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 833
Default Worksheet name

Hi Walrus. I think that the only thing to do is to type them in separately.

I am not aware that you can pull one from the other automatically.

Please hit Yes if my comments have helped.

Thanks.

"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Worksheet name

Hi,

Right click your sheet tab, view code and paste the code in. Change A1 to
the cell you want

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
On Error Resume Next
Application.EnableEvents = False
ActiveSheet.Name = Target.Value
Application.EnableEvents = True
End If
End Sub

Mike

"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Worksheet name

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Worksheet name

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Worksheet name

Walrus

That code will get you into trouble because you aren't trapping for illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Worksheet name

Mike

Where should i include this "On Error resume next"??



"Mike H" wrote:

Walrus

That code will get you into trouble because you aren't trapping for illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Worksheet name

Hi,

Like this

Sub name_um()
On Error Resume Next
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub

Mike

"walrus" wrote:

Mike

Where should i include this "On Error resume next"??



"Mike H" wrote:

Walrus

That code will get you into trouble because you aren't trapping for illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Worksheet name

Walrus, the sheet event will change the sheet name as soon as the cell value
is changed. The macro which you posted needs to be run separately to change
the tab names

--
Jacob


"walrus" wrote:

Mike

Where should i include this "On Error resume next"??



"Mike H" wrote:

Walrus

That code will get you into trouble because you aren't trapping for illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Worksheet name

Mike/Jacob

Thanks. This works even better as i don't have to worry about older tabs
being renamed.

Regards,


"Jacob Skaria" wrote:

Walrus, the sheet event will change the sheet name as soon as the cell value
is changed. The macro which you posted needs to be run separately to change
the tab names

--
Jacob


"walrus" wrote:

Mike

Where should i include this "On Error resume next"??



"Mike H" wrote:

Walrus

That code will get you into trouble because you aren't trapping for illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to launch
VBE (Visual Basic Editor). From the left treeview search for the workbook
name and click on + to expand it. Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what i type
in a specific cell?

Regards,



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 834
Default Worksheet name

Nor did yours trap it, it just ignored it. Better to handle it IMO

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then
Application.EnableEvents = False
ActiveSheet.Name = ValidName(Target.Value)
Application.EnableEvents = True
End If
End Sub

Function ValidName(ByVal TheFileName As String) As String
Dim RegEx As Object
Set RegEx = CreateObject("vbscript.regexp")
RegEx.Global = True
RegEx.Pattern = "[\\/:\*\?""<\|]"
ValidName = RegEx.Replace(TheFileName, "")
Set RegEx = Nothing
End Function



---
HTH

Bob Phillips

"Mike H" wrote in message
...
Walrus

That code will get you into trouble because you aren't trapping for
illegal
file names
Include the error trap I posted at the top of your code

On Error resume next

Mike

"walrus" wrote:

Thanks guys...i found and used the following VBA Function and it worked
perfectly.

Sub name_um()
For Each ws In Worksheets
ws.Name = ws.Range("D1").Value
Next
End Sub



"Jacob Skaria" wrote:

Just to add on to what Mike has posted.

If you are looking at naming all tabs in a workbook use the workbook
level
Sheet Change event. Incase you are new to VBA set the security level to
low/medium in (Tools|Macro|Security). From workbook press Alt+F11 to
launch
VBE (Visual Basic Editor). From the left treeview search for the
workbook
name and click on + to expand it. Within that you should see the
following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code
pane.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If Target.Address = "$A$1" And Target.Text < "" Then
On Error Resume Next
Application.EnableEvents = False
Sh.Name = Target.Text
Application.EnableEvents = True
End If
End Sub

--
Jacob


"walrus" wrote:

Hi

What should i do so that the Worksheet (Tab) name is the same as what
i type
in a specific cell?

Regards,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 05:24 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Excel Discussion (Misc queries) 2 August 24th 06 05:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet [email protected] Excel Worksheet Functions 2 August 24th 06 05:26 PM
plot graph from multiple worksheet as embedded chart object on every worksheet jeftiong New Users to Excel 0 August 23rd 06 01:50 PM
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet Aster Excel Worksheet Functions 3 March 12th 06 10:58 AM


All times are GMT +1. The time now is 05:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"