Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Automatically Advancing by a Month

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: Automatically Advancing by a Month.

Jim has a need to advance the date in a particular cell by one month at midnight on the 14/15 of each month (00:00:00 on the 15th), and he wondered how it could be done.

As with many problems in Excel, the answer depends on the nature of the data involved and exactly what you want to do. If the date in the cell is today's date, and you simply want to have the cell display the current month up through the 14th, and then next month after that, then you can use a formula such as the following:

=CHOOSE(IF(DAY(NOW())>14,MONTH(NOW())+1,MONTH(NOW())),
"January","February","March","April","May","June",
"July","August","September","October","November",
"December","January")

This formula returns the name of a month, not a date. If you prefer to have a date returned, you can use this formula:

=IF(DAY(NOW())>14,DATEVALUE(IF(MONTH(NOW())=12,1,
MONTH(NOW())+1) & "/" & DAY(NOW()) & "/" & IF(MONTH(
NOW())=12,YEAR(NOW())+1,YEAR(NOW()))),NOW())

Both of these formulas account for the "end of year wrap-around" when you advance from December to January. A shorter version of this last formula can be created if you use the DATE function instead of the DATEVALUE function:

=DATE(YEAR(NOW()),MONTH(NOW())+((DAY(NOW())>14)*1),1)

This formula, unlike the DATEVALUE example, always returns a date that is the first day of any given month.

If you really want to advance the value of a particular date in a cell, then you must use a macro to do the task. Further, you must make sure that the macro only runs once a month, at a particular time on a particular day. For instance, if you wanted the macro to run at 00:00:00 on the 15th of each month, you would need to set up the macro so that it checked the date and time, and then ran at that particular date and time. You would also need to make sure that the workbook containing the macro was open over that date and time.

The following macro will fetch the date from a cell and increase it by a month. The macro assumes that you have a named range, DateCell, which refers to the cell to be updated.

Sub IncreaseMonth()
    Dim dDate As Date
    dDate = Range("DateCell").Value
    Range("DateCell").Value = _
      DateSerial(Year(dDate), _
      Month(dDate) + 1, Day(dDate))
End Sub

To make sure that the macro runs at the appropriate time, you would need another macro. The following macro is designed to be run whenever the workbook is opened:

Private Sub Workbook_Open()
If Day(Now) = 14 Then
    Application.OnTime ("23:59:59"), "IncreaseMonth"
End If
End Sub

Notice that this particular macro sets the OnTime method so that it runs the IncreaseMonth macro at 23:59:59 on the 14th. This date and time was chosen because it is easier to catch than is 00:00:00 on the 15th.

Remember that the IncreaseMonth macro will only run if you open the workbook on the 14th, and then leave the workbook open until the 15th.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2180) 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: Automatically Advancing by a Month.

Related Tips:

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Ohisio John    17 Sep 2016, 13:52
Dear Allen Wyatt,

I used this function between Months. e.g from September to October. The function works well. This is how I did it but when the system, I meant when entering into a new Month, it showed me From October To October (the same Month). It does not show me From October To November. What could the error ?.

for September is below
=CHOOSE(IF(DAY(NOW())>14,MONTH(NOW())+0,MONTH(NOW())),
"January","February","March","April","May","June",
"July","August","September","October","November",
"December","January")

for October is below
=CHOOSE(IF(DAY(NOW())>14,MONTH(NOW())+1,MONTH(NOW())),
"January","February","March","April","May","June",
"July","August","September","October","November",
"December","January")

Please help.
Vasile    05 Nov 2015, 00:01
hello to get the current month I think the bellow formula is more useful and shorter:

=PROPER(TEXT(NOW();"mmmm"))
Barry    04 Aug 2014, 14:10
@Chetan

Using the EDATE function incrementing 31-Oct-2013 by 1 month gives 30-Nov-2013, incrementing 31-Oct-2013 by 4 months would give 28-Feb-2104 (and incrementing 31-Oct-2011 by 4 months would give 29-Feb-2012 as 2012 is a leap year).

@SM 10
I don't know idf you've figured this out by now - it's a year since you posted your request. But for anyone else the following function does what you want:

=TEXT(EDATE(A1-21,1),"mmmm") - assuming the date is in cell A1
Michael (Micky) Avidan    03 Aug 2014, 09:30
To my opinion (if I correctly understood the task) the best and shortest way will be:
=IF(DAY(NOW())>14,EDATE(NOW(),1),NOW())
*** In the old versions (2000-2007) the EDATE function is part of the Analysis Toolpak Add-In, which comes with Excel, but needs to be activated.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL
chetan    02 Aug 2014, 18:33
If date is is 31.10.2013 then how you will increase by one month. If you do this it will increase to 1.12.2013
SM10    26 Apr 2013, 10:31
I want to do a similar type of formula as above however I want to be able to display a specific month depending on the date.

for example
If the date entered between 22/01/2013 and 21/02/2013 I want to display February.
If the date entered between 22/02/2013 and 21/02/2013 I want to display March.
If the date entered between 22/03/2013 and 21/04/2013 I want to display April.
And so on and so on....

How can I do this using a simple formula?

 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.