Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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


goodInsert Workbook Information

Kutools for Excel's Insert Workbook Information utility can quickly insert sheet name, path, user name and
so on to a cell, header or footer.
doc 1

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 120 handy functions, makes your jobs easier. 

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

Click Enterprise > 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 last modify name2
doc insert workbook information

arrow blue right bubble Insert Workbook Information


Insert Blank Rows & Columns(insert multiple blank rows/columns at once, or insert blank rows/columns every nth row/col...)

doc insert blank row

Related article:

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


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mnemonic · 2 years ago
    Thanks for the Info.
  • To post as a guest, your comment is unpublished.
    Gunel · 3 years ago
    perfect.very useful
    ;-)
  • To post as a guest, your comment is unpublished.
    John R. · 4 years ago
    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.
    • To post as a guest, your comment is unpublished.
      Tom R. · 3 years ago
      @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.
  • To post as a guest, your comment is unpublished.
    Genna · 4 years ago
    I tried this technique but could only get it to show up on one sheet. Help?
  • To post as a guest, your comment is unpublished.
    Joe B. · 4 years ago
    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!