PDA

View Full Version : Solved: Previous Month



satyen
03-20-2010, 05:25 AM
I would like some vba code How do I enter in a cell some vba code that shows the previous month and current year. Example if doing today it would be
Feb- 2010.

Many Thanks

mdmackillop
03-20-2010, 05:52 AM
Sub LastMonth()
ActiveCell = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmm-yy")
End Sub


or
=DATE(YEAR(TODAY()),MONTH(TODAY())-1,1)
and format as required.

satyen
03-20-2010, 06:06 AM
perfect thanks, !!