Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Noting the Workbook Creation Date.

Noting the Workbook Creation Date

by Allen Wyatt
(last updated December 6, 2014)

6

When you are developing a worksheet, you may need to keep track of certain information about your workbook. For instance, you might want to place the creation date of a workbook into a cell. While Excel does provide some worksheet functions for dates (such as NOW or TODAY), it does not provide a worksheet function to access the workbook creation date.

This means that the answer lies in using a macro. For instance, you might create a macro that would determine the current date and input it (as text) into a particular cell. This macro could then be run whenever you created a new workbook by naming the macro Auto_Open. The following is an example of such a macro:

Sub Auto_Open()
    If Worksheets.Application.Range("A1") = "" Then
        Worksheets.Application.Range("A1") = Format(Date, "long Date")
    End If
End Sub

The macro checks to see what is in cell A1. If there is nothing there, then it puts the text version of today's date in there. If there is something already there (which there would be every time you subsequently open the workbook), then the information is left intact and unscathed.

Perhaps the most satisfactory approach, however, is to actually access the operating system and pull the file creation date for the current workbook. This can be done with the following macro function:

Function CreateDate() As String
    Dim Temp As String

    On Error Resume Next
    Temp = CreateObject("scripting.filesystemobject"). _
      GetFile(ActiveWorkbook.Name).dateCreated
    If Err.Number <> 0 Then
        CreateDate = "Not Saved"
    Else
        CreateDate = Left(Temp, InStr(Temp, " ") - 1)
    End If
    On Error Goto 0
End Function

Notice that this approach isn't tied to a particular cell in your worksheet. To use the macro, simply put the following in any cell of your worksheet:

=CreateDate()

The function returns either "Not Saved" (if the workbook is brand new and hasn't been saved before) or it returns a text value that represents the date on which the workbook was created.

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

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

Using the Object Browser

Efficiently navigating through a document, particularly as it gets longer, can be a perpetual challenge. One tool you can use ...

Discover More

Running Macros on Hidden Worksheets

Excel allows you to hide worksheets so that they aren't visible to those using your workbook. Hiding worksheets has a ...

Discover More

Files Opening Slowly If Many Files Exist

Managing large numbers of documents in Word can lead to some interesting challenges. One potential challenge is that your ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Forcing a Workbook to Close after Inactivity

Tired of your workbooks being left open on the screen where they can be seen by anyone passing by? Here's a way to have Excel ...

Discover More

Comparing Workbooks

Do you need to compare two workbooks to each other? While you can use specialized third-party software to do the comparisons, ...

Discover More

Creating Individual Workbooks

Workbooks can contain many worksheets. If you want to pull a workbook apart and create a whole series of workbooks based on ...

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 3 - 2?

2015-10-13 12:20:45

3R

Can someone provide the definitions for the following?
Created
Modified
Accessed
While the definitions seem evident, I need to prove when a document was saved to the server. Does the Created definition provide the evidence?


2014-12-09 12:03:54

Glenn Case

Also, to answer Paul's question:

ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")


2014-12-09 12:01:27

Glenn Case

This is easier, as you don't need to use scripting. TO access the creation date from VBA, use the following:

ActiveWorkbook.BuiltinDocumentProperties("Creation Date")


2014-12-07 13:35:57

David Harte

(For Paul) I haven't confirmed this but I'm pretty sure that to retrieve when the workbook file was last SAVED the same basic macro can be used but with the Temp variable set to the 'dateLastModified' property instead of the 'dateCreated' property (oh, and the name of the macro no doubt changed to call it SaveDate or something similar).


2014-12-06 07:39:25

sheldon hopkins

An easier (and more informative) method

Add a worksheet to your workbook. In this version history worksheet:
col a date of editing workbook
col b version (incremental)
col c module affected
col d brief description of change

Now you have a record of your workbook's history


2014-12-06 07:03:42

Paul Van den Bossche

Interesting tip !
But ... Is there a way to put the (time and) date in a cel that tells when the sheet was SAVED the last time ?

thanks in advance !


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.