Previous month based on current month

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
830
Office Version
  1. 365
Platform
  1. Windows
I am using the following formula to return the current month.

=TEXT(TODAY(),"MMMM")

However I would like to return the previous month. I know that if it were the year, I can just add -1 to the end of the formula, but that returns #VALUE when tried with the MMMM format.

Thanks,
Matthew
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Not sure how spectraflame's answer will respond when it is January...

Here's my solution:

=TEXT(DATE(2004,IF(MONTH(TODAY())-1>0,MONTH(TODAY())-1,12),1),"MMMM")

K
 
Upvote 0
Thanks sbendbuckeye and kkknie,

kkknie - I changed the date on my PC and you were correct. If the current month is January, December is not returned with sbendbuckeye's formula.

Thank you both for the input.

Matthew
 
Upvote 0
Alternative

For the first of the previous month (e.g. 1/12/2011):
=EOMONTH(TODAY(),-2)+1

For the previous month as a number:
=month(EOMONTH(TODAY(),-2)+1)

For the previous month in full:
=text(EOMONTH(TODAY(),-2)+1,"mmmm")
 
Upvote 0
In evey one of these formulas you can replace TODAY() with NOW().

Saves a couple of keystrokes! :)
 
Upvote 0
Today() and Now() are volatile functions, better not use them.
The next function uses Date instead, and gives more flexibility, and saves a lot more keystrokes :)

Code:
Public Function PrevMonth() As String
Dim d As Date
d = DateSerial(Year(Date), Month(Date) - 1, 1)
PrevMonth = Format(d, "MMMM", vbMonday, vbFirstJan1)
End Function
 
Upvote 0

Forum statistics

Threads
1,222,636
Messages
6,167,221
Members
452,104
Latest member
jadethejade

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