Results 1 to 7 of 7

Thread: [RESOLVED] [Excel 2003] Change format of Date/Time in Header/Footer

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Resolved [RESOLVED] [Excel 2003] Change format of Date/Time in Header/Footer

    Currently when I set the values for the Header and Footer I am limited on the
    Date and Time to using &[Date] and &[Time] which respectively give me, for
    example, 12/11/2008 and 16:06

    Is there any way that I can set the format to something else, similar to using
    a Format(now,"dd mmmm yyyy") command.
    Signature Under Construction

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    you can put a formatted date, but it will not update,
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    Hi westconn1,

    I want the Date and Time in my footers to be the date/time when printed, so
    inserting the actual date as formatted text is not an option.

    Given the confusion that can easily arise when the month is given as a
    numeric I want to be able to display the month using the Text name.

    In Word I can insert a Field using my choice of formatting into a header or
    footer, surely I should be able to do the same in Excel.
    Signature Under Construction

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    I want the Date and Time in my footers to be the date/time when printed, so
    inserting the actual date as formatted text is not an option.
    Is this what you want?

    Instead of Now below, capture the date and time the moment print command is used...

    vb Code:
    1. Sub Change_Format()
    2.     'For left footer
    3.     ActiveSheet.PageSetup.LeftFooter = Format(Now, "dd mmmm yyyy")
    4.    
    5.     'for Center footer
    6.     ActiveSheet.PageSetup.CenterFooter = Format(Now, "dd mmmm yyyy")
    7.        
    8.     'for Right footer
    9.     ActiveSheet.PageSetup.RightFooter = Format(Now, "dd mmmm yyyy")
    10. End Sub
    Last edited by Siddharth Rout; Nov 27th, 2008 at 05:56 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    Hmm, not quite.

    I believe if I was to use that that I would need to use a
    Workbook_BeforePrint or Worksheet_BeforePrint command to update the
    footer to ensure that I got the correct Date and Time.

    Is there any way to change the format used by the &[Date] and &[Time]
    values placed in the Custom Header and Custom Footer to give Date and Time?
    Signature Under Construction

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    i believe the only way would be to put a formatted string each time, in the before print event, also you would need to declare the application with events for that to work

    excel only stores the &D in the footer which is converted to date at printing, it does not even use system short date format
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2006
    Location
    Best Place on Earth
    Posts
    363

    Re: [Excel 2003] Change format of Date/Time in Header/Footer

    Pity, the formatting is for Workbooks which are being generated by Excel Workbooks.

    One of the requirements for the generated Workbooks is that they be lean, mean and macro free.

    Maybe I will be able to use the Before Print method another time.
    Signature Under Construction

Posting Permissions

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



Click Here to Expand Forum to Full Width