And then press F5 key to run this code, and your specified date format has been inserted into the header or footer at once. Note: In the above code, you can change the CenterHeader to LeftHeader, CenterFooter…, and the date format mmmm dd, yyyy also can be changed as you need.Ĥ. VBA code: Insert and format date in header or footer: Sub add_date_header()Ī = Format(Date, "mmmm dd, yyyy") Click Insert > Module, and paste the following code in the Module Window. Hold down the ALT + F11 keys in Excel to open the Microsoft Visual Basic for Applications window.ģ. Activate your worksheet which you want to insert and format the date in header or footer, and then click Page Layout button on the lower right corner of the workbook to enable the page layout view, see screenshot:Ģ. Here, I will introduce some simple VBA code for you to solve this task in Excel, please do as follows:ġ. Specify date or date time format in header or footer with VBA code In this case, how could you change the date or date time format to your own need in header or footer as following screenshot shown? Normally, when you insert date or time into the header or footer with the & or & code, the date or time format is based on the regional settings controlled by Windows. How to specify date or datetime format in header or footer?
0 Comments
Leave a Reply. |