|
-
Nov 26th, 2008, 11:06 AM
#1
Thread Starter
Hyperactive Member
[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 
-
Nov 26th, 2008, 03:52 PM
#2
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
-
Nov 27th, 2008, 05:44 AM
#3
Thread Starter
Hyperactive Member
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 
-
Nov 27th, 2008, 05:52 AM
#4
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:
Sub Change_Format()
'For left footer
ActiveSheet.PageSetup.LeftFooter = Format(Now, "dd mmmm yyyy")
'for Center footer
ActiveSheet.PageSetup.CenterFooter = Format(Now, "dd mmmm yyyy")
'for Right footer
ActiveSheet.PageSetup.RightFooter = Format(Now, "dd mmmm yyyy")
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
-
Nov 27th, 2008, 07:16 AM
#5
Thread Starter
Hyperactive Member
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 
-
Nov 30th, 2008, 01:25 AM
#6
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
-
Dec 1st, 2008, 04:47 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|