PDA

View Full Version : macro for last months date



buhay
09-22-2010, 01:19 PM
I use the following macro to display the text "at the end of september". How do I change it so that it displays last months name instead of the current month.
The text should be "at the end of august"

Selection.TypeText Text:="at the end of" & " " & Format(Now, "mmmm")

Thanks in advance

gmaxey
09-22-2010, 02:20 PM
Selection.TypeText Text:="at the end of" & " " & Format(DateAdd("M", -1, Now), "mmmm")

buhay
09-22-2010, 03:05 PM
Selection.TypeText Text:="at the end of" & " " & Format(DateAdd("M", -1, Now), "mmmm")

Thank you so much! I love this forum:)