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
 
Are the 12 sheets named "Sheet1", "Sheet2", "Sheet3", ….. "Sheet12"?
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
No, Q1data1, Q1data2, Q1data3 This represent the first quarter, then Q2data1, Q2data2,Q3data3, and so on to Q4data3
 
Upvote 0
Do the names of any of the other sheets contain the word "data"?
 
Upvote 0
Try:
Code:
Sub myTabName()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, x As Long
    x = 0
    For Each ws In Sheets
        If ws.Name Like "*data*" Then
            ws.Name = Replace(DateAdd("m", x, Range("A1").Value), "/", "-")
            x = x + 1
        End If
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Good morning. I am still having an issue with this that I thought I could solve but can't. The dates on the tabs still show as month day and year (9/1/2018). I tried to change the code part "m":
Code:
[COLOR=#333333]Replace(DateAdd("m"[/COLOR]
to mm, yyyy and so on and the name tabs remain the same. This not a big issue other than makes the tabs too big.
Thanks
 
Upvote 0
The "m" doesn't affect the format of the cell. The macro increases the tab name by one month at a time. The "m" simply tells the macro to increase by month rather than day or year. Try re-formatting the cells that have dates to the format that you want.
 
Last edited:
Upvote 0
Thanks for the reply. I tried that as well and still showed the month day and year. It is not a big deal; I am very happy not having to change the tab names manually every year.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

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