Return previous month based on current month

This tutorial shows how to return the previous month based on the current month through the use of Excel formulas or VBA

Example: Return previous month based on current month

Return previous month based on current month

METHOD 1. Return previous month based on current month

EXCEL

=TEXT(TODAY()-DAY(TODAY()),"mmmm")
This formula uses a combination of Excel TEXT, TODAY and DAY functions to calculate the previous month based on the current month. The formula uses the TODAY function to return today's date and then removes the number of days that have gone past this month through the use of the DAY(TODAY()). This will return the last date of the previous month, which in this case would be 31/12/2018. Then using the TEXT function with the "mmmm" criteria the formula returns the month from the date, which in this example in December.

METHOD 2. Return previous month based on current month

EXCEL

=TEXT(EOMONTH(TODAY(),-1),"mmmm")
This formula uses a combination of Excel TEXT, EOMONTH and TODAY functions to calculate the previous month based on the current month. The formula uses the EOMONTH and TODAY functions, with the months criteria as -1 to return the last date of the previous month, which in this case would be 31/12/2018. Then using the TEXT function with the "mmmm" criteria the formula returns the month from the date, which in this example in December.

METHOD 1. Return previous month based on current month using VBA

VBA

Sub Previous_Month_based_on_Current_Month()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return the previous month based on the current month
ws.Range("C4") = Format(DateAdd("m", -1, Date), "mmmm")

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C4") in the VBA code.
Worksheet Selection: Select the worksheet where you want to return the previous month based on the current month by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.

Explanation about the formulas used to calculate previous month based on current month

EXPLANATION

EXPLANATION

This tutorial shows and explains how to calculate the previous month based on the current month using Excel formulas or VBA.
This tutorial provides two Excel methods that can be applied to return the previous month based on the current month. The first method uses a combination of the TEXT, TODAY and DAY functions whilst the second method uses the TEXT, EOMONTH and TODAY functions. Both of the formulas work in a similar way, where they calculate the last date of the previous month and then using the TEXT function with the "mmmm" criteria to return the month.
This tutorial provides one VBA method that can be applied to return the previous month based on the current month.
FORMULA (first method)
=TEXT(TODAY()-DAY(TODAY()),"mmmm")
FORMULA (second method)
=TEXT(EOMONTH(TODAY(),-1),"mmmm")

RELATED TOPICS

Related Topic Description Related Topic and Description
How to return the next month based on the current month using Excel and VBA methods
How to return the next month based on the current month using Excel and VBA methods
How to return the previous month based on a specific date using Excel and VBA methods
How to return the next month based on a specific date using Excel and VBA methods
How to previous year based on the current year using Excel and VBA methods

RELATED FUNCTIONS

Related Functions Description Related Functions and Description
The Excel TEXT function returns a numeric value as text, in a specified format
The Excel TODAY function returns the current date
The Excel DAY function returns the day from a specified date