Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to make tab name match cell on another sheet?

I have a set of tabs in a workbook template. I would like to have some of the
exsisting tabs automatically rename according to specific cells on another
sheet.

example:
cells 1-10 in column A of the 1st tab have text: "Week01" - "Week10"

name of 2nd tab = cell A1 in 1st tab ("Week01").
name of 3rd tab = cell A2 in 1st tab ("Week02").
name of 4th tab = cell A3 in 1st tab ("Week03").
......and so on.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to make tab name match cell on another sheet?

You don't even need that extra worksheet.

This assumes that you either deleted it or moved it to the far right. (I used
worksheets 1 to 10--starting from the far left and going right.)

Option Explicit
sub testme()
dim wCtr as long
for wctr = 1 to 10
worksheets(wctr).name = "Week" & format(wctr,"00")
next wctr
end sub

This doesn't do any checking--if you don't have 10 sheets, it'll blow up. If
there's an existing worksheet already named Week09, it'll blow up.



kAustin79 wrote:

I have a set of tabs in a workbook template. I would like to have some of the
exsisting tabs automatically rename according to specific cells on another
sheet.

example:
cells 1-10 in column A of the 1st tab have text: "Week01" - "Week10"

name of 2nd tab = cell A1 in 1st tab ("Week01").
name of 3rd tab = cell A2 in 1st tab ("Week02").
name of 4th tab = cell A3 in 1st tab ("Week03").
.....and so on.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to make tab name match cell on another sheet?

Where did you place this code. I right-clicked the first tab, selected 'view
code', and put it in there. Did I do this correctly? It's not working for me.

"Dave Peterson" wrote:

You don't even need that extra worksheet.

This assumes that you either deleted it or moved it to the far right. (I used
worksheets 1 to 10--starting from the far left and going right.)

Option Explicit
sub testme()
dim wCtr as long
for wctr = 1 to 10
worksheets(wctr).name = "Week" & format(wctr,"00")
next wctr
end sub

This doesn't do any checking--if you don't have 10 sheets, it'll blow up. If
there's an existing worksheet already named Week09, it'll blow up.



kAustin79 wrote:

I have a set of tabs in a workbook template. I would like to have some of the
exsisting tabs automatically rename according to specific cells on another
sheet.

example:
cells 1-10 in column A of the 1st tab have text: "Week01" - "Week10"

name of 2nd tab = cell A1 in 1st tab ("Week01").
name of 3rd tab = cell A2 in 1st tab ("Week02").
name of 4th tab = cell A3 in 1st tab ("Week03").
.....and so on.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default How to make tab name match cell on another sheet?

The code would go in a standard code Module. What you did was put it in the
Worksheet module of the sheet you right clicked on. That is one way to get
to the VBEditor (ALT+F11 is another), but once there you need to insert a
standard code Module into your VBAProject. On the left is a directory tree
listing open workbooks and any Add-Ins you have running (.xla). Right click
on your workbook project and Insert/Module. you can now Cut and Paste the
code from the Worksheet module to the standard Module. It should run OK from
there.

Mike F
"kAustin79" wrote in message
...
Where did you place this code. I right-clicked the first tab, selected
'view
code', and put it in there. Did I do this correctly? It's not working for
me.

"Dave Peterson" wrote:

You don't even need that extra worksheet.

This assumes that you either deleted it or moved it to the far right. (I
used
worksheets 1 to 10--starting from the far left and going right.)

Option Explicit
sub testme()
dim wCtr as long
for wctr = 1 to 10
worksheets(wctr).name = "Week" & format(wctr,"00")
next wctr
end sub

This doesn't do any checking--if you don't have 10 sheets, it'll blow up.
If
there's an existing worksheet already named Week09, it'll blow up.



kAustin79 wrote:

I have a set of tabs in a workbook template. I would like to have some
of the
exsisting tabs automatically rename according to specific cells on
another
sheet.

example:
cells 1-10 in column A of the 1st tab have text: "Week01" - "Week10"

name of 2nd tab = cell A1 in 1st tab ("Week01").
name of 3rd tab = cell A2 in 1st tab ("Week02").
name of 4th tab = cell A3 in 1st tab ("Week03").
.....and so on.


--

Dave Peterson



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
How do I make a cell = the sheet name? adam Excel Discussion (Misc queries) 3 May 22nd 09 01:04 AM
make all cells in same row match cell formatted with fill color zjopa Excel Discussion (Misc queries) 2 May 21st 08 04:26 AM
I need to make cell a1 on sheet 2 ALWAYS = a1 on sheet 1 tarabull Excel Worksheet Functions 3 March 26th 08 07:04 PM
How to make columns in one sheet match columns from another sheet Zoe Hu Excel Discussion (Misc queries) 5 December 4th 07 06:53 PM
Using VB to change sheet name to match cell contents Gary Paxson Excel Programming 4 May 24th 04 08:38 PM


All times are GMT +1. The time now is 06:43 PM.

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

About Us

"It's about Microsoft Excel"