PC Review


Reply
Thread Tools Rate Thread

Automatic tab naming

 
 
Rex
Guest
Posts: n/a
 
      20th Feb 2009
Using Excel 2003

I have a workbook with approx. 70 worksheets. I need to automatically name
only 50 of the worksheet tabs with cell references from the 1st worksheet.

On the first worksheet, cells B50 through B100 contain the names for the
other 50 tabs. Each of the 50 worksheets reference a cell from the first
worksheet in cell D4 (the 1st one references (Tab1)B50, 2nd = (Tab1)B51, 3rd
= (Tab1)B52, etc.) I inserted the following code into the workbook:

Private Sub Workbook_Open()
Dim wks As Worksheet

On Error Resume Next
For Each wks In Worksheets
wks.Name = wks.Range("D4").Value
Next wks
On Error GoTo 0
End Sub

Here are some of the issues I am having that I need help with:
1. When I add names in the first worksheet and then save the file and
re-open, it changes the names of the 50 worksheets. It doesn’t do it until
after I reopen and enable macros. I can live with this if I have to but if
there is a way to get the code to fire right away I would like to know.
2. This code obviously renames all worksheet tab names with their cell D4
contents and I only want the specific 50 tabs to rename themselves.
3. If I only enter text or numbers in 10 of the cells on the first tab, the
11th worksheet is named “0”.
4. If I delete some of the names from the first tab, save the file and
reopen it, the worksheets that should now have no name keep the name they
originally had.

I appreciate any help you can give…..
Thanks



--
Rex Munn
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      20th Feb 2009

The modifications below might help with the 0 Name
and the naming of sheets in excess of 50. In regard
to the sheets having their original names after they
had been changed to no name, Excel will automatically
name them if you don't. It is a built in default.


Private Sub Workbook_Open()
Dim wks As Worksheet
On Error Resume Next
For Each wks In Worksheets
If wks.Range("D4").Value <> "" Then
wks.Name = wks.Range("D4").Value
End If
If wks.Index > 50 Then Exit For
Next wks
On Error GoTo 0
End Sub





"Rex" wrote:

> Using Excel 2003
>
> I have a workbook with approx. 70 worksheets. I need to automatically name
> only 50 of the worksheet tabs with cell references from the 1st worksheet.
>
> On the first worksheet, cells B50 through B100 contain the names for the
> other 50 tabs. Each of the 50 worksheets reference a cell from the first
> worksheet in cell D4 (the 1st one references (Tab1)B50, 2nd = (Tab1)B51, 3rd
> = (Tab1)B52, etc.) I inserted the following code into the workbook:
>
> Private Sub Workbook_Open()
> Dim wks As Worksheet
>
> On Error Resume Next
> For Each wks In Worksheets
> wks.Name = wks.Range("D4").Value
> Next wks
> On Error GoTo 0
> End Sub
>
> Here are some of the issues I am having that I need help with:
> 1. When I add names in the first worksheet and then save the file and
> re-open, it changes the names of the 50 worksheets. It doesn’t do it until
> after I reopen and enable macros. I can live with this if I have to but if
> there is a way to get the code to fire right away I would like to know.
> 2. This code obviously renames all worksheet tab names with their cell D4
> contents and I only want the specific 50 tabs to rename themselves.
> 3. If I only enter text or numbers in 10 of the cells on the first tab, the
> 11th worksheet is named “0”.
> 4. If I delete some of the names from the first tab, save the file and
> reopen it, the worksheets that should now have no name keep the name they
> originally had.
>
> I appreciate any help you can give…..
> Thanks
>
>
>
> --
> Rex Munn

 
Reply With Quote
 
Rex
Guest
Posts: n/a
 
      25th Feb 2009
Thanks. That helped.
--
Rex Munn


"JLGWhiz" wrote:

>
> The modifications below might help with the 0 Name
> and the naming of sheets in excess of 50. In regard
> to the sheets having their original names after they
> had been changed to no name, Excel will automatically
> name them if you don't. It is a built in default.
>
>
> Private Sub Workbook_Open()
> Dim wks As Worksheet
> On Error Resume Next
> For Each wks In Worksheets
> If wks.Range("D4").Value <> "" Then
> wks.Name = wks.Range("D4").Value
> End If
> If wks.Index > 50 Then Exit For
> Next wks
> On Error GoTo 0
> End Sub
>
>
>
>
>
> "Rex" wrote:
>
> > Using Excel 2003
> >
> > I have a workbook with approx. 70 worksheets. I need to automatically name
> > only 50 of the worksheet tabs with cell references from the 1st worksheet.
> >
> > On the first worksheet, cells B50 through B100 contain the names for the
> > other 50 tabs. Each of the 50 worksheets reference a cell from the first
> > worksheet in cell D4 (the 1st one references (Tab1)B50, 2nd = (Tab1)B51, 3rd
> > = (Tab1)B52, etc.) I inserted the following code into the workbook:
> >
> > Private Sub Workbook_Open()
> > Dim wks As Worksheet
> >
> > On Error Resume Next
> > For Each wks In Worksheets
> > wks.Name = wks.Range("D4").Value
> > Next wks
> > On Error GoTo 0
> > End Sub
> >
> > Here are some of the issues I am having that I need help with:
> > 1. When I add names in the first worksheet and then save the file and
> > re-open, it changes the names of the 50 worksheets. It doesn’t do it until
> > after I reopen and enable macros. I can live with this if I have to but if
> > there is a way to get the code to fire right away I would like to know.
> > 2. This code obviously renames all worksheet tab names with their cell D4
> > contents and I only want the specific 50 tabs to rename themselves.
> > 3. If I only enter text or numbers in 10 of the cells on the first tab, the
> > 11th worksheet is named “0”.
> > 4. If I delete some of the names from the first tab, save the file and
> > reopen it, the worksheets that should now have no name keep the name they
> > originally had.
> >
> > I appreciate any help you can give…..
> > Thanks
> >
> >
> >
> > --
> > Rex Munn

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Sheet Naming Jeff Lowenstein Microsoft Excel Programming 4 11th Mar 2008 01:49 PM
Automatic Sheet Naming Jeff Lowenstein Microsoft Excel Programming 0 11th Mar 2008 12:27 PM
Automatic naming of ranges Pedo00ab Microsoft Excel Misc 1 12th Feb 2004 01:07 PM
Automatic naming of files Alan Dresch Microsoft Excel Misc 2 4th Feb 2004 10:36 AM
Automatic sheet naming Hans Weustink Microsoft Excel Programming 3 23rd Oct 2003 09:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 PM.