Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Date Last Edited.

Date Last Edited

by Allen Wyatt
(last updated February 27, 2016)

10

As part of setting up a worksheet, you may want the header or footer to contain the date that the workbook was last edited. Excel doesn't maintain this information, but it does allow you to perform macros whenever certain events occur, such as changes to a workbook. All you need to do is add a macro such as the following to the ThisWorkbook object in the VBA Editor:

Private Sub Workbook_SheetChange(ByVal _
  Sh As Object, ByVal Target As Excel.Range)
    ActiveSheet.PageSetup.CenterFooter = _
      "Worksheet Last Changed: " & _
      Format(Now, "mmmm d, yyyy hh:mm")
End Sub

The macro results in each footer on each worksheet in the workbook having separate dates and times on them, since each worksheet would be updated at different times. You can change the destination property (.CenterFooter) to one of the other header or footer properties (.LeftHeader, .CenterHeader, .RightHeader, .LeftFooter, .RightFooter) as desired.

You may want the header or footer to instead include the date that the workbook was last saved. (This is what many people really view as the "last edit date.") The information is visible in the Properties dialog box for a worksheet, but Excel has no menu selection or other command that allows you to insert this date into a header or footer. Instead, you must use a macro to add the desired information.

The best way to accomplish the task is to add a macro to the ThisWorkbook object that is triggered just before a workbook is saved:

Private Sub Workbook_BeforeSave(ByVal _
  SaveAsUI As Boolean, Cancel As Boolean)
    Dim sht
    For Each sht In Sheets
        sht.PageSetup.CenterFooter = _
          "Workbook Last Saved: " & _
          Format(Now, "mmmm d, yyyy hh:mm")
    Next
End Sub

This macro steps through each worksheet in the workbook and changes every center footer to have the date that the workbook was saved.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11604) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Date Last Edited.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Defining and Using Custom Colors

Want to spice up your worksheets with your own custom colors? Here's how to define them easily.

Discover More

Checking for Sentences Beginning with Conjunctions

In my English classes in junior high, I would get marked down if I started sentences with a conjunction. ("There's a reason ...

Discover More

Borders on Multiple Paragraphs with Differing Indents

When you place a border around a paragraph, the position of that border is determined, partially, by the indent with which ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Changing Page Number Format

Need your page numbers to not appear as regular Arabic numerals? Here's a way to get them to appear in a different way--in ...

Discover More

Using a Different Footer on Secondary Pages

When printing a worksheet, you may want to have the footer different on the first page of your document than it is on ...

Discover More

Ampersands in Headers and Footers

Add an ampersand to the text in a header or footer and you may be surprised that the ampersand disappears on your printout. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one more than 9?

2016-03-01 05:46:15

Manfred

@ Walter, should also work

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
ActiveSheet.PageSetup.LeftFooter = _
"Worksheet Last Changed: " & _
Format(Now, "dd-mmm-yyyy hh:mm") &_
vbLf & _
"by: " & Application.UserName
End Sub


2016-02-29 11:45:25

Derek Gerry

Walter, The code below will get the user name for you.

Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Function ap_GetUserName() As Variant

Dim strUserName As String
Dim lngLength As Long
Dim lngResult As Long

'-- Set up the buffer
strUserName = String$(255, 0)
lngLength = 255

'-- Make the call
lngResult = wu_GetUserName(strUserName, lngLength)

'-- Assign the value
ap_GetUserName = Left(strUserName, InStr(1, strUserName, Chr(0)) - 1)

End Function


2016-02-29 11:39:45

Michael (Micky) Avidan

@Abdul hamid,
In case Peter Atherton better understood your request, than I did, try the following macro (make sure you have at least 12 sheets in your Workbook):
-----------------
Sub NameSheets()
On Error Resume Next
For M = 1 To 12
Worksheets(M).Name = MonthName(M)
Next
End Sub
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-02-29 11:19:19

Peter Atherton

Abdul

I don't know what happened to the code, You do want to rname the sheets?

Sub NameSheets()
Dim i As Integer
Dim va As Variant
On Error GoTo 0
va = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
For i = 1 To Worksheets.Count
Worksheets(i).Name = va(i - 1) & format(Year(Now()), "-yy")
Next i
End Sub


2016-02-29 07:45:25

Walter A

I have a shared workbook with several named sheets, how would you change the macro to the last user and date? the user is unique to the computer and in code so their name doesn't actually appear.


2016-02-29 05:26:10

Michael (Micky) Avidan

@ABDUL HAMID,
If you prefer a Macro - try the following (change the value of the variable Num from 1-12):
Sub MonthsName()
Num = 5
MsgBox MonthName(Num)
End Sub
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-02-29 05:19:46

Michael (Micky) Avidan

@ABDUL HAMID,
Suppose you have the number 5 un cell A1.
In cell B1 type: =DATE(2016,A1,1) and custom format that cell as: mmmm.
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)
ISRAEL


2016-02-28 19:52:18

Paul

Hi. I have a spreadsheet that is on a shared drive accessed by 1/2 dozen people, but the actual spreadsheet is not "shared" as such - i.e. only one person can open it at a time.
Is there a way to record who last saved the sheet?


2016-02-28 10:43:27

Peter Atherton

Abdul

Try this macro, it uses month short name and adds the last two digits of the year.

To change the names in the array fill the rest of the month''s name between each quotation.

To remove the year change the line Worksheets(i).Name = va(i - 1) & format(Year(Now()), "-yy")

to
Worksheets(i).Name = va(i - 1)

HTH


2016-02-27 05:35:22

ABDUL HAMID

How to convert Month in letter format mean if any excel sheet numbers are written like 1,2,3,4 etc and required to be converted in letter like January,February,March,April etc.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.