Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Code for name of previous month

I have added text in to my email that goes like:

"please provide numbers for MMMM month end" - where MMMM is the name of the previous month.

So it it's April today, MMMM will show March.

I have the following code:

Dim newDate: newDate = DateAdd("M", -1, Now)

But the result comes out to be 27/03/2017 16:37:58

I want it to show March.

Any suggestions?

like image 630
wasimakram101 Avatar asked Dec 04 '25 14:12

wasimakram101


1 Answers

Format the return as "MMMM":

Dim newDate: newDate = Format(DateAdd("M", -1, Now), "MMMM")
like image 184
Scott Craner Avatar answered Dec 06 '25 03:12

Scott Craner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!