Forum Discussion
Joe Cangelosi
May 02, 2018Copper Contributor
Format Date in header and footer
Hi everyone, I like to stamp PDFs of excel docs with the current time and date via the footer (or header). The "insert current date" function inserts the date in my system's default (DD/MM/YYYY)...
- May 02, 2018
Hi Joe,
It seems that there is no option to change the format through the Current Date and Current Time elements.
They always give you the date and time based on the default date format of the OS.
The format will not change unless you changed the default date format of the OS.
Regards
Kasra_Afrough
Dec 13, 2023Copper Contributor
Hello dear Joe,
You can use below code into "Worksheet_Activate" section in Excel (any version).
For Left Header Section:
Private Sub Worksheet_Activate()
ActiveSheet.PageSetup.LeftHeader = "&""Arial,Standaard""&16Date: " & Format(Now(), "d mmmm yyyy")
End Sub
OR
For Right Header Section:
Private Sub Worksheet_Activate()
ActiveSheet.PageSetup.RightHeader = "&""Arial,Standaard""&16Date: " & Format(Now(), "d mmmm yyyy")
End Sub
Note: The number between "&" and "Date" (16) is the font size.
You can change it as you wish!
______________
When you active (select) this sheet (with any name), the VBA set the date format of this sheet automatically and when you go to "Print Preview", the date will set based on your formatting order and current date.
Enjoy!
You can use below code into "Worksheet_Activate" section in Excel (any version).
For Left Header Section:
Private Sub Worksheet_Activate()
ActiveSheet.PageSetup.LeftHeader = "&""Arial,Standaard""&16Date: " & Format(Now(), "d mmmm yyyy")
End Sub
OR
For Right Header Section:
Private Sub Worksheet_Activate()
ActiveSheet.PageSetup.RightHeader = "&""Arial,Standaard""&16Date: " & Format(Now(), "d mmmm yyyy")
End Sub
Note: The number between "&" and "Date" (16) is the font size.
You can change it as you wish!
______________
When you active (select) this sheet (with any name), the VBA set the date format of this sheet automatically and when you go to "Print Preview", the date will set based on your formatting order and current date.
Enjoy!