Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Sheets for Days.

Sheets for Days

Written by Allen Wyatt (last updated December 14, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003


9

When you are starting a new workbook, it is very common to name each worksheet after a different day of the month. If you do this quite a bit, you know it can be tiresome to rename each worksheet, in turn, to exactly what you need.

The following macro was developed to help in these situations. It checks the names of the worksheets in your workbook, renaming them to the days of the month if they begin with the letters "Sheet". If there are not enough sheets in the workbook, it adds sheets, as necessary, for each day of the month.

Sub DoDays()
    Dim J As Integer
    Dim K As Integer
    Dim sDay As String
    Dim sTemp As String
    Dim iTarget As Integer
    Dim dBasis As Date

    iTarget = 13
    While (iTarget < 1) Or (iTarget > 12)
        iTarget = Val(InputBox("Numeric month?"))
        If iTarget = 0 Then Exit Sub
    Wend

    Application.ScreenUpdating = False
    sTemp = Str(iTarget) & "/1/" & Year(Now())
    dBasis = CDate(sTemp)
    
    For J = 1 To 31
        sDay = Format((dBasis + J - 1), "dddd mm-dd-yyyy")
        If Month(dBasis + J - 1) = iTarget Then

            If J <= Sheets.Count Then
                If Left(Sheets(J).Name, 5) = "Sheet" Then
                    Sheets(J).Name = sDay
                Else
                    Sheets.Add.Move after:=Sheets(Sheets.Count)
                    ActiveSheet.Name = sDay
                End If
            Else
                Sheets.Add.Move after:=Sheets(Sheets.Count)
                ActiveSheet.Name = sDay
            End If
        End If
    Next J

    For J = 1 To (Sheets.Count - 1)
        For K = J + 1 To Sheets.Count
            If Right(Sheets(J).Name, 10) > _
              Right(Sheets(K).Name, 10) Then
                Sheets(K).Move Before:=Sheets(J)
            End If
        Next K
    Next J

    Sheets(1).Activate
    Application.ScreenUpdating = True
End Sub

The macro sets each tab name equal to the day of the week followed by the actual date, as in "Wednesday 03-28-2012." If you want to change the way that the tabs are named for each day, just change how the sDay variable is constructed in the macro.

The last step in the macro is that it places the worksheets in proper order, based on the days of the month. The result is that if you have any other worksheets left in the workbook (in other words, you had some that did not begin with the letters "Sheet," then those worksheets end up at the end of the workbook, after the sheets for each day.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2836) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Sheets for Days.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Starting a Discussion

Tips for getting your Discussion started.

Discover More

Inserting from the Clip Art Gallery Doesn't Work

Ever insert a picture and it won't display in your document? It could be due to some of the display settings in Word. ...

Discover More

Copying a Set Range from Multiple Worksheets to a New Worksheet

Want to create a summary worksheet that pulls a single row of data from each worksheet in the workbook? Here are a couple ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Referencing Worksheet Tabs

Ever want to use the name of a worksheet tab within a cell? Here's how you can access that information using the CELL ...

Discover More

Increasing Font Size In Worksheet Tabs

While Excel does not have an intrinsic way to change the font in on a worksheet tab, Windows does.

Discover More

Changing the Height of Worksheet Tabs

Do you need your worksheet tabs to be taller than what they are? You can't make the adjustment in Excel, but you can make ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 5 + 5?

2022-03-07 12:42:36

Brittany

hi! Can you tell me how to get it to copy a template page now for each day?


2021-04-27 11:33:25

Dawn N.

This worked brilliantly for all the dates in the current year but I need to continue the tabs for the following year till June 30th. Is there a way to have this continue for 2022? Thanks in advance for your help.

Dawn


2017-11-29 14:27:19

macro challenged

@Willy Vanhaelen
Thank you very much.

(I cannot see comments posted before October - they must not be set to display)


2017-11-08 12:23:01

Willy Vanhaelen

@macro challenged
In the macros of my comment of 4 August 2017 in the Exelribbon version of this tip (https://excelribbon.tips.net/T011523_Sheets_for_Days)
change
For X = 1 To X
to
For X = X To 1 Step -1

There is no way to run a macro unless the workbook is Macro enabled.


2017-11-07 17:34:27

macro challenged

Hi You Are a HERO!!

This is what I want to do, do you know how I would reverse order the sheets? I want first of the month all the way to the right.

Another question? Is there any way that I can run this in the immediate window (I am not able to email excel sheets with Macro enabled)

Thanks


2017-10-25 11:35:15

Willy Vanhaelen

@Jeff
Read carefully my comment. The second macro can do all you ask for. Try it.


2017-10-25 06:41:42

Jeff

Thank you for this macro!

Is there a way to exclude certain days (Saturday and Sunday)?

Is there a way to have this macro work for months in future years, say January 2018?


2017-10-24 07:32:12

Willy Vanhaelen

@Tyler
Take a look at my comment of 4 August 2017 in the Exelribbon version of this tip (https://excelribbon.tips.net/T011523_Sheets_for_Days). Perhaps that is what you are lloking for?


2017-10-23 20:23:46

Tyler

This is exactly what I've been trying to do. Is there a way to have this select a specific template for the new sheets? I have a report I run everyday and if I can get this to work like I think it can, that would be amazing.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.