2nd name tab to show next month from first tab name

mrjinx007

Board Regular
Joined
Jul 28, 2011
Messages
51
Hi,
I have this macro that works fine; it copies the date from a cell in that sheet to the tab name.
Code:
[COLOR=#000000][FONT=Menlo]Sub myTabName()[/FONT][/COLOR]    ActiveSheet.Name = ActiveSheet.Range("A1") [COLOR=#000000][FONT=Menlo]End Sub[/FONT][/COLOR]
How can I modify it so it can change the other 11 tabs so I have a full year of monthly tabs in sequence?
Thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Assuming each sheet has the date you want in A1 of each sheet:

Code:
sub loopsheets
Dim Current As Worksheet


         ' Loop through all of the worksheets in the active workbook.
         For Each Current In Worksheets
if current.visible = true 'only visible sheets
current.name = current.range("A1")
endif
           
         Next
end sub
 
Upvote 0
Try:
Code:
Sub myTabName()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, x As Long
    x = 0
    For Each ws In Sheets
        ws.Name = Replace(DateAdd("m", x, Range("A1").Value), "/", "-")
        x = x + 1
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
I'm not sure which macro you are referring to. If you are using the one I suggested, make sure that the sheet with the date in A1 is the active sheet when you run the macro.
 
Upvote 0
Thanks mumps. It gave me a runtime error this time and froze up. Waiting for it to shutdown and try again.

Well I put it on a new form with just 12 tabs and it worked fine. Could it be because I have additional sheets there?
 
Last edited:
Upvote 0
You are very welcome. :) It will work regardless of the number of sheets. It will simply increase the month by 1 for each sheet.
 
Upvote 0
Okay, so, is it possible that I have this formula in the sheets that follow the first one have this formula
Code:
=EDATE(Nov!AB2,1)
in them to do the same thing? Also, anyways to have the tab name show just the month?
 
Upvote 0
Okay,
This time it worked just fine. However, it changed all the (25) tab names to dates instead of the 11 tabs in front sheet that the code is written on.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top