Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Automatically copy the file name to the worksheet tab

How can I automatically insert the file name into the worksheet tab in Excel
2003? Or for that matter, any data in a cell into the tab label? (Without
manually typing it in?)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Automatically copy the file name to the worksheet tab

Private Sub Worksheet_Change(ByVal Target As Range)
''autoname the worksheet Tab from value in A1 or as filename
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Me.Name = ActiveWorkbook.Name
'if you want value from a cell to be the sheet name
'Me.Name = .Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 11 Jul 2007 09:16:03 -0700, Bob wrote:

How can I automatically insert the file name into the worksheet tab in Excel
2003? Or for that matter, any data in a cell into the tab label? (Without
manually typing it in?)


  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Automatically copy the file name to the worksheet tab

Gord,

thanks for your reply. I'm not sure what to do with this. Where would I
enter this piece of code?

Bob

"Gord Dibben" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
''autoname the worksheet Tab from value in A1 or as filename
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Me.Name = ActiveWorkbook.Name
'if you want value from a cell to be the sheet name
'Me.Name = .Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 11 Jul 2007 09:16:03 -0700, Bob wrote:

How can I automatically insert the file name into the worksheet tab in Excel
2003? Or for that matter, any data in a cell into the tab label? (Without
manually typing it in?)



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Automatically copy the file name to the worksheet tab

Apologies Bob.

This is sheet event code.

Right-click on the sheet tab and "View Code".

Copy/paste into that sheet module.

Edit the "A1" to whatever cell you want to use.

Note the single quote marks before the two lines. They will not run.

I stuck them in there so's you have a choice of a cell value or the workbook.

Remove the quote from 'Me.Name = .Value and add a quote to

Me.Name = ActiveWorkbook.Name

'if you want value from a cell to be the sheet name.....is just a comment.


Gord


On Wed, 11 Jul 2007 17:26:01 -0700, Bob wrote:

Gord,

thanks for your reply. I'm not sure what to do with this. Where would I
enter this piece of code?

Bob

"Gord Dibben" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
''autoname the worksheet Tab from value in A1 or as filename
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Me.Name = ActiveWorkbook.Name
'if you want value from a cell to be the sheet name
'Me.Name = .Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 11 Jul 2007 09:16:03 -0700, Bob wrote:

How can I automatically insert the file name into the worksheet tab in Excel
2003? Or for that matter, any data in a cell into the tab label? (Without
manually typing it in?)




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
Copy data into another worksheet and have it update automatically? Taxed Mind Excel Discussion (Misc queries) 4 October 6th 06 12:17 AM
Automatically copy data from one worksheet to another karstens Excel Worksheet Functions 2 August 1st 06 07:56 AM
Copy data automatically onto a separate worksheet Ree Excel Discussion (Misc queries) 1 May 11th 06 07:18 PM
Copy File Automatically on Opening It Dolores Excel Discussion (Misc queries) 4 December 30th 05 07:12 PM
automatically copy data from one worksheet to another LC Excel Worksheet Functions 1 July 23rd 05 03:36 AM


All times are GMT +1. The time now is 06:00 AM.

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"