Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Month in header (WIN XP/Excel2003)

    I am using the following code in my header:
    With ActiveSheet.PageSetup
    .LeftHeader = ""
    .CenterHeader = ActiveSheet.Name & Format(Date, "m-yyyy")

    This gives me the current month and year.


    How would I write this if I wanted "NEXT" month and current year? (08/2005)

    Thanks as always !!

    Michael

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Month in header (WIN XP/Excel2003)

    Use

    Format(DateAdd("m", 1, Date), "m-yyyy")

    DateAdd takes 3 arguments: the interval ("m" for month), the number of intervals to add (1 in this case) and the starting date (today).

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Month in header (WIN XP/Excel2003)

    Once again, Hans, I tip my hat to you. 4 minutes !!!

    Thank you for sharing your knowledge.

    Michael

  4. #4
    3 Star Lounger
    Join Date
    Jan 2004
    Location
    Birmingham, West Midlands, United Kingdom
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Month in header (WIN XP/Excel2003)

    Less time than it took you, Michael, to say thinks!

    **grin** **grin**

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Month in header (WIN XP/Excel2003)

    Hey John !
    You're right. I was so excited <img src=/S/groovin.gif border=0 alt=groovin width=21 height=21> that I had to use the code first THEN I came back to thank Hans.

    You guys are great - thanks so much for helping us out.

    Michael

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Month in header (WIN XP/Excel2003)

    You mean it took you longer to use it than it took Hans to write it? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Legare Coleman

  7. #7
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Sacramento, California, USA
    Posts
    491
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Month in header (WIN XP/Excel2003)

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

Posting Permissions

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