Find previous quarter and display as Q3 or Q4

571202

New Member
Joined
May 26, 2019
Messages
17
​Hi, I would like to be able to determine the previous quarter from the current date and display as Q2 or Q3 or Q4 etc.<o:p></o:p>
<o:p> </o:p>
I have the code to find and display the previous month (see below) but am unable to find a similar one for quarter. Thanks in advance.<o:p></o:p>
Code:
Range("A4") = Format(DateAdd("m", -1, Date), " mmm yy")
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,886
Code:
Sub test()
Dim dt As Date
dt = DateAdd("m", -1, Date)
Range("A4") = Format(dt, " mmm yy")
Range("A5") = "Q" & -Int(-Month(dt) / 3)
End Sub
 

Forum statistics

Threads
1,082,501
Messages
5,365,942
Members
400,863
Latest member
kimtid

Some videos you may like

This Week's Hot Topics

Top