Skip to main content

How to insert last modified date in Excel header or footer?

In Excel, we can quickly and easily insert the workbook information, such as file name, file full path, current date and so on into the header or footer. But have you ever tried to insert last modified date and time of the worksheet into them? Excel doesn’t provide this feature for us to insert the last modified date in header or footer, and here, I will introduce you a handy way to solve it.

Insert last modified date in Excel header or footer with VBA code

Insert last modified date/created date/userto header/footer with Kutools for Excel good idea3


arrow blue right bubble Insert last modified date in Excel header or footer with VBA code

The following simple VBA code can help you to insert last saved date and time of the worksheet in to the header or footer, please do as this:

1. Activate your worksheet that you want to insert the last modified date into the header or footer.

2. Then hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

3. In the left VBAProject pane, double click ThisWorkbook to open the Module, then copy and paste the following code.

VBA code: Insert last modified date in header or footer

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "Last saved: " & Format(Date, "mm-dd-yy") & " " & Time
End Sub

doc-insert-last-saved-date-to-header-1

4. Then save and close this code, and go to click View > Page Layout to view the result. And you can see the last modified date and time has been inserted into the center header. See screenshots:

doc-insert-last-saved-date-to-header-2
-1
doc-insert-last-saved-date-to-header-3

Notes:

1. The last modified date and time is updated automatically, when you modify and save the Excel file.

2. If you need to insert this last saved date and time into the left header/footer, right header/footer or center footer, you just need to change the CenterHeader in the above code to your request.


arrow blue right bubble Insert last modified date/created date/userto header/footer with Kutools for Excel

With Kutools for Excel, you can uset the Insert Workbook Information tool to quickly insert the workbook information to header, footer, or a cell.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Click Kutools Plus > WorkbookInsert Workbook Information, and in the popping dialog, check the information you want to insert , and go to Insert at section, check Range, Header or Footer option, and specify to insert at left header/footer, center header/footer or right header/footer to meet your need.
doc insert workbook information
doc insert workbook information

arrow blue right bubble Insert Workbook Information


Related article:

Get and insert the created time and last modified time in cells

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Why do I have to load the VB code into 'ThisWorkBook' of the VBAproject for every new workbook created? I would think that if I loaded the VB code into 'ThisWorkBook' of VBAHOME (PERSONAL.XLSB) if would be retained and available cresting new workbooks
This comment was minimized by the moderator on the site
Just tried it after moving the center header to the left footer. Didn't work. What I saved at 1:20 pm still recorded as 1:00 pm. Your help would be most appreciated. BTW, my spreadsheet was created as Excel 2007, and I made changes at the library on Excel 2016. Generally, I can go back and forth between versions with no problems.
Also, I didn't realize my name would be published. Any chance of changing it to Nancy E.?
Many thanks!
This comment was minimized by the moderator on the site
THANK YOU! That was invaluable. Who'd believe that Microsoft would exclude such an important function! What about Word? Is it done the same way now?
This comment was minimized by the moderator on the site
Thanks for the Info.
This comment was minimized by the moderator on the site
perfect.very useful ;-)
This comment was minimized by the moderator on the site
I did this and it works. I saved the file as .xlsx and closed it. Now, when I open it, I open the VBA coding window but I am not able to find this chunk of code to edit it. I would like to play with location and remove time. Thank you.
This comment was minimized by the moderator on the site
@John R. When you get to the VBA coding window, on the left section of the screen you need to double-click "ThisWorkbook" to open the right section of the screen. Then in the right section (at the top) you need to select "Workbook" and "BeforeSave". That should hopefully show you the chunk of code that you're looking for.
This comment was minimized by the moderator on the site
I tried this technique but could only get it to show up on one sheet. Help?
This comment was minimized by the moderator on the site
Thanks! I maintain an employee phone number and extension list. People get hired, quit, move to different extensions. If someone wants a copy I print it off, but it only showed the date and time it was printed -- not necessarily the most current information. It was difficult to tell if you had two different copies which one was the most up-to-date. Showing the last time the file was saved will do what I wanted!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations