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: Determining Month Names for a Range of Dates.

Determining Month Names for a Range of Dates

Written by Allen Wyatt (last updated April 25, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


1

Anita has a worksheet with over 10,000 rows. Each row represent an individual contract. Each contract has a start date (column A) and an end date (column B). She needs a way to list in columns C, D, E, etc. the individual months covered by the contract. For instance, if column A contains 01 July 2009 and column B contains 30 September 2009, she needs column C to contain Jul 09, column D to contain Aug 09, and column E to contain Sep 09. Whatever formulas are used need to accommodate contract lengths that may be quite different.

There are several ways to go about such a task. It is possible to use some intermediate columns that specify things like the starting month and the number of months of each contract, but it turns out that such intermediate columns are not necessary. For instance, assuming that your contracts start in row 2, you could place the following formula in cell C2:

=TEXT(A2,"mmm yy")

Then, beginning in cell D2 you could place this formula:

=IF(DATE(YEAR($A2),MONTH($A2)+COLUMNS($D2:D2),
DAY($A2))>$B2,"",TEXT(DATE(YEAR($A2),MONTH($A2)
+COLUMNS($D2:D2),DAY($A2)),"mmm yy"))

This is one formula, and it uses the position of the cells containing the formula, along with the contract starting date, to calculate, basically, the month of offset from that starting month. The formula can be copied toward the right (columns E, F, G, etc.) for as far as necessary to display all the months and years.

The one drawback to the formula is that if the contract ending date is earlier in the month than the contract starting date, then the last month is not displayed. Thus, if the contract starts on 12 June 2012 and it ends on 05 February 2013, then the last month (February) will not be displayed by the formula. You could, instead, use the following formula in cell C2 and copy it to the right as far as necessary:

=IF(DATE(YEAR($A2),MONTH($A2)+COLUMN()-2,0)
>DATE(YEAR($A2),MONTH($B2)+1,0),"",TEXT(DATE
(YEAR($A2),MONTH($A2)+COLUMN()-2,0),"mmm yy"))

This formula also relies on the columns in which it resides, using them to calculate an offset from the contract start date. The formula will work just fine, regardless of the relationship between the contract start and end dates.

If you don't want to rely on column positioning, there is another approach you can take. Place the following formula in cell C2:

=(A2)

Then, in cell D2 place the following formula:

=IF($B2>C2,EOMONTH(C2,1),"")

Copy the formula in D2 to the right as many cells as necessary, and then format all those cells (including C2 and D2) as dates that display only the month and year. The formula will look at B2 (the contract ending date) to see if it is larger than C2. If it is, then the formula returns the serial number of the last day of the next month in series. If it is not, then a blank ("") is returned.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5406) 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: Determining Month Names for a Range 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

Calculating Differences in Months using Non-Standard Date Values

Dates can be entered into a worksheet in any number of unique or novel ways. Working with those dates can be a challenge, ...

Discover More

Coloring Identical Company Names

Want to know where duplicates are in a list of names? There are a couple of ways you can go about identifying the ...

Discover More

Selecting a Bookmark in a Macro

Bookmarks can be very handy in a document. Word provides a VBA command you can use to easily select any of those bookmarks.

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

ISO Week Numbers in Excel

Work in an industry that uses ISO standards when it comes to working with dates? You'll love the formula in this tip ...

Discover More

Converting European Dates to US Dates

Those in Europe use a date format that is different than those in the US; this is not news. But what if you need to ...

Discover More

Every Second Tuesday

Need a way to enter dates from every second Tuesday (or some other regular interval)? Excel makes it easy, providing ...

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 five more than 3?

2020-12-30 21:47:40

Eleanor

Hi Allen,
This is great! But as the months name would be available in individual cells and not the column header, do you know how to create a chart with the x-axis being the month and year names (Mar 2020) and the y-axis being the type of contracts e.g. (type contract A consists of contract 1, 2 3 , type contract B consists of contract 4,5, 6 etc)? Would really appreciate your help on this!


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.