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

Generating a List of Dates

Written by Allen Wyatt (last updated June 8, 2024)
This tip applies to Word 97, 2000, 2002, and 2003


1

For some documents, it is helpful to have a list of dates that you can use as the basis for your work. For instance, you may have to create a report that lists all the dates between now and the end of the year, along with a person's name or a project name to the right of the date. The starting point, of course, is getting the list of dates.

There are a couple of ways you can approach generating the list. One easy method is to use Excel in conjunction with Word. Excel's AutoFill feature makes generating a list of dates amazingly easy. Once you have the list in Excel, you can then copy and paste it into the Word document, or you can use mail merge to merge the dates into the document (if that approach is appropriate for your needs).

If you prefer to not use Excel for some reason, the best solution is to use a macro. The following macro very quickly creates a list of all the dates for the year 2015:

Sub PrintYearDays()
    Dim DateToday As Date
    Dim T As Integer

    'Because the date is going to be changed, save it
    DateToday = Date
    Date = #12/31/2014#

    For T = 1 To 365
        Selection.TypeText Text:=Format(Date + T, _
          "mmmm dd yyyy")
        Selection.TypeParagraph
    Next T

    'Restore today's date
    Date = DateToday
End Sub

Notice that the macro works by resetting the date on your system. Today's current date is stored in the DateToday variable, and then the date is reset to the starting date for your range. If you want to have the macro work for some other date range, just change the starting date, along with the ending value of the For ... Next loop.

If you need to create date lists, and you never quite know what the beginning and ending dates in the range will be, then a different macro approach makes more sense. The following macro asks you for both a beginning and ending date:

Sub ListDates()
    Dim ListDate as Date
    Dim StartDate As Date
    Dim EndDate As Date
    Dim Repeats As Integer

    'Gets user input
    StartDate = InputBox("Please enter the starting date.", _
      "Start Date", "Start Date")
    EndDate = InputBox("Please enter the ending date.", _
      "End Date", "End Date")

    'Enters the start date in the document
    Selection.TypeText Text:=Format(StartDate, _
      "dddd, MMMM dd, yyyy")
    Selection.TypeText (vbCr & vbLf)

    'Determines the number of dates to print
    Repeats = DateDiff("d", StartDate, EndDate)

    'Loops to print the list of dates
    For i = 1 To Repeats
        ListDate = DateAdd("d", i, StartDate)
        Selection.TypeText Text:=Format(ListDate, _
          "dddd, MMMM dd, yyyy")
        Selection.TypeParagraph
    Next i
End Sub

The StartDate and EndDate variables, set by your input, determines how many times the For ... Next loop is repeated.

Note:

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

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (3864) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Generating a List of Dates.

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

Deleting Dates within Text Strings

Finding and replace dates contained within other text in a cell can be a bit tricky. This tip looks at some approaches to ...

Discover More

Displaying the First Worksheet in a Macro

When creating macros, you often have to know how to display individual worksheets. VBA provides several ways you can ...

Discover More

Naming Tabs for Weeks

Need to set up a workbook that includes a worksheet for each week of the year? Here's a couple of quick macros that can ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

Sharing Headings with Others

Headings form the outline of your document and hopefully give it an easy-to-follow organization. If you want to share ...

Discover More

Quickly Finding Synonyms

If you need to find some synonyms for a specific word in your document, here's how you can do it. (Hint: All you need to ...

Discover More

Entering a Page Break from the Keyboard

Need to force Word to move text to the top of the next page? It's easy when you use the keyboard shortcut for a page break.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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 2 + 2?

2024-06-10 08:10:53

Paul Hanson

I used the second macro - the first one choked on this line:
Date = #12/31/2014#


This Site

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

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.