Consulting

Results 1 to 3 of 3

Thread: macro for last months date

  1. #1

    macro for last months date

    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"

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

    Thanks in advance

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Selection.TypeText Text:="at the end of" & " " & Format(DateAdd("M", -1, Now), "mmmm")
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Quote Originally Posted by gmaxey
    Selection.TypeText Text:="at the end of" & " " & Format(DateAdd("M", -1, Now), "mmmm")
    Thank you so much! I love this forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •