Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Rename existing tabs

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Rename existing tabs

for each sh in Thisworkbook.Worksheets
sh.name = sh.Name & "aa"
Next

--
regards,
Tom Ogilvy


"Dawn Rhoads" wrote in message
...
I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the

next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for

Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Rename existing tabs

What I understand is that you have a workbook which has a worksheet called
Master and you want to copy that Master worksheet 30/31 times and rename each
with a Date. For instance the first tab as 1, the second tab as 2 and so on.
If this is what you require then the following will do it

Sub Test()
Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i
End Sub

After it does the creation of the sheets, manually delete the tabs not
required.

Alok Joshi
"Dawn Rhoads" wrote:

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Rename existing tabs

Yes

"Dawn Rhoads" wrote:

Oh that's beautiful, that works like a charm, thank you! When I have to
change the year, do I just change the number "2005" in both places in the
code to the current year?

Thanks again for your help!

"Alok" wrote:

This should do it

Sub Test2()
Dim i%
Dim m As Variant
m = InputBox("Enter Month Number Jan=1, Feb=2..", "Month")
If m = "" Then Exit Sub
For i = Day(DateSerial(2005, Val(m) + 1, 0)) To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = Format(DateSerial(2005, Val(m), i), "mm-dd-yy")
Next i
End Sub

Alok Joshi

"Dawn Rhoads" wrote:

Thanks Alok! This is pretty close to what I need, and is actually better
than what I was thinking in that it creates all 31 sheets each time, which
will make it easier if I have to update the format of the sheet. Cool!

The only thing I would like differently is for the tab names not to be just
numbered 1-31. I would like them to be the actual dates. 5-1-05, 5-2-05,
etc. If this is too complicated, I do think just using the numbers 1-31
will be acceptable. But if you have an idea on how to get the actual date
onto each tab, that would be great.

Thanks for your help!

"Alok" wrote:

What I understand is that you have a workbook which has a worksheet called
Master and you want to copy that Master worksheet 30/31 times and rename each
with a Date. For instance the first tab as 1, the second tab as 2 and so on.
If this is what you require then the following will do it

Sub Test()
Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i
End Sub

After it does the creation of the sheets, manually delete the tabs not
required.

Alok Joshi
"Dawn Rhoads" wrote:

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Rename existing tabs

This should do it

Sub Test2()
Dim i%
Dim m As Variant
m = InputBox("Enter Month Number Jan=1, Feb=2..", "Month")
If m = "" Then Exit Sub
For i = Day(DateSerial(2005, Val(m) + 1, 0)) To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = Format(DateSerial(2005, Val(m), i), "mm-dd-yy")
Next i
End Sub

Alok Joshi

"Dawn Rhoads" wrote:

Thanks Alok! This is pretty close to what I need, and is actually better
than what I was thinking in that it creates all 31 sheets each time, which
will make it easier if I have to update the format of the sheet. Cool!

The only thing I would like differently is for the tab names not to be just
numbered 1-31. I would like them to be the actual dates. 5-1-05, 5-2-05,
etc. If this is too complicated, I do think just using the numbers 1-31
will be acceptable. But if you have an idea on how to get the actual date
onto each tab, that would be great.

Thanks for your help!

"Alok" wrote:

What I understand is that you have a workbook which has a worksheet called
Master and you want to copy that Master worksheet 30/31 times and rename each
with a Date. For instance the first tab as 1, the second tab as 2 and so on.
If this is what you require then the following will do it

Sub Test()
Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i
End Sub

After it does the creation of the sheets, manually delete the tabs not
required.

Alok Joshi
"Dawn Rhoads" wrote:

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Rename existing tabs

Thanks Alok! This is pretty close to what I need, and is actually better
than what I was thinking in that it creates all 31 sheets each time, which
will make it easier if I have to update the format of the sheet. Cool!

The only thing I would like differently is for the tab names not to be just
numbered 1-31. I would like them to be the actual dates. 5-1-05, 5-2-05,
etc. If this is too complicated, I do think just using the numbers 1-31
will be acceptable. But if you have an idea on how to get the actual date
onto each tab, that would be great.

Thanks for your help!

"Alok" wrote:

What I understand is that you have a workbook which has a worksheet called
Master and you want to copy that Master worksheet 30/31 times and rename each
with a Date. For instance the first tab as 1, the second tab as 2 and so on.
If this is what you require then the following will do it

Sub Test()
Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i
End Sub

After it does the creation of the sheets, manually delete the tabs not
required.

Alok Joshi
"Dawn Rhoads" wrote:

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Rename existing tabs

Oh that's beautiful, that works like a charm, thank you! When I have to
change the year, do I just change the number "2005" in both places in the
code to the current year?

Thanks again for your help!

"Alok" wrote:

This should do it

Sub Test2()
Dim i%
Dim m As Variant
m = InputBox("Enter Month Number Jan=1, Feb=2..", "Month")
If m = "" Then Exit Sub
For i = Day(DateSerial(2005, Val(m) + 1, 0)) To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = Format(DateSerial(2005, Val(m), i), "mm-dd-yy")
Next i
End Sub

Alok Joshi

"Dawn Rhoads" wrote:

Thanks Alok! This is pretty close to what I need, and is actually better
than what I was thinking in that it creates all 31 sheets each time, which
will make it easier if I have to update the format of the sheet. Cool!

The only thing I would like differently is for the tab names not to be just
numbered 1-31. I would like them to be the actual dates. 5-1-05, 5-2-05,
etc. If this is too complicated, I do think just using the numbers 1-31
will be acceptable. But if you have an idea on how to get the actual date
onto each tab, that would be great.

Thanks for your help!

"Alok" wrote:

What I understand is that you have a workbook which has a worksheet called
Master and you want to copy that Master worksheet 30/31 times and rename each
with a Date. For instance the first tab as 1, the second tab as 2 and so on.
If this is what you require then the following will do it

Sub Test()
Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i
End Sub

After it does the creation of the sheets, manually delete the tabs not
required.

Alok Joshi
"Dawn Rhoads" wrote:

I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Rename existing tabs

Thinking about this, I can actually combine these two macros do what I am
trying to do! I can use Alok's macro to generate 31 uniquely numbered tabs,
then I can use Tom's macro to append the appropriate month's number to the
beginning of each tab.

If anyone can think of a way to have Tom's macro ask me which month and year
I want to add to the tab, that would be great. But this combination of the
two works wonderfully -- even if I need to edit the macro each time I run it
that's a vast improvement over my current manual system! Thanks so much for
your help, guys!

Sub Macro2()

Dim i%
For i = 31 To 1 Step -1
Worksheets("Master").Copy After:=Worksheets(1)
ActiveSheet.Name = i
Next i

For Each sh In ThisWorkbook.Worksheets
sh.Name = "07-" & sh.Name & "-05"
Next


End Sub
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Rename existing tabs

Hi -- thanks, I tried this but what it seems to do is add "aa" to the
existing name of each tab? (Do I understand correctly what this macro is
doing?) This doesn't quite work for my purposes since it adds the exact same
thing to each tab.

Each of my tabs is named with a specific date. So when I create my workbook
for June, the tab called 5-1-05 needs to be renamed 6-1-05, 5-2-05 needs to
be renamed 6-2-05, etc. So I guess I really need the macro to replace the
first number, whatever it is. Ideally, I guess it would ask me what number I
want to use. I suppose it would also work if it just looked at the current
number and added one.

Thanks again for for any help you can offer, I appreciate it!

"Tom Ogilvy" wrote:

for each sh in Thisworkbook.Worksheets
sh.name = sh.Name & "aa"
Next

--
regards,
Tom Ogilvy


"Dawn Rhoads" wrote in message
...
I have a monthly worksheet that requires one worksheet tab for each day.
Every month, I take my master sheet and manually rename each tab for the

next
month.

Is there any way this could be done with a macro? If so, can someone
provide sample code? I have some experience with recording macros for

Word,
but I'm definitely no programmer, so I can't actually write one myself!
Thanks for any help anyone can provide!




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
rename worksheet tabs fix me Excel Worksheet Functions 3 March 12th 13 01:19 PM
I want to rename my worksheet tabs... Dr. Darrell Excel Discussion (Misc queries) 5 July 13th 09 03:05 PM
rename tabs May Excel Discussion (Misc queries) 5 February 14th 07 11:45 PM
Rename all existing worksheet tabs MikeM Excel Discussion (Misc queries) 14 October 20th 06 03:29 AM
Programatically Rename Tabs Karl Burrows[_2_] Excel Programming 1 February 21st 05 01:00 PM


All times are GMT +1. The time now is 03:50 AM.

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"