+ Reply to Thread
Results 1 to 9 of 9

Displaying Last modified date and time of file in a cell

  1. #1
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79

    Displaying Last modified date and time of file in a cell

    How can display the last modified date and time of my excel file in a particular cell - Say in cell E1.

    This is the same value that we get when we Right Click excel file->Properties->General and look at the label "Modified".

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Displaying Last modified date and time of file in a cell

    How to use the macro:

    1. Open up your workbook
    2. Right-click the Excel icon to the left of FILE Menu
    3. Select VIEW CODE
    4. Copy and Paste in your code (given below) in the ThisWorkbook module that appears
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. When you save your sheet, the current time stamp will be updated in cell E1.


    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79

    Re: Displaying Last modified date and time of file in a cell

    So I tried the above code, but it does not work. I don't get any time stamp when I close and re-open the file. The cell E1 is blank.

    I am using Excel 2002 version. I am attaching a sample file with the VBA code in it (Sheet1).
    Attached Files Attached Files

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Displaying Last modified date and time of file in a cell

    code needs to go in workbook module not work sheet module
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79

    Re: Displaying Last modified date and time of file in a cell

    Quote Originally Posted by martindwilson View Post
    code needs to go in workbook module not work sheet module
    That worked just fine....

  6. #6
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79

    Re: Displaying Last modified date and time of file in a cell

    Sorry I take my words back. It didn't quite do what I was hoping for it.

    The current code updates the time stamp even if I don't modify the file. Looks like it is showing the last access/open time instead of the last modified date.

    I am looking for the last modified time as mentioned in my first post.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Displaying Last modified date and time of file in a cell

    Move the code to the BeforeSave event (still goes in the ThisWorkbook module).
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Displaying Last modified date and time of file in a cell

    Edit...deleted as unnecessary.

  9. #9
    Registered User
    Join Date
    12-20-2012
    Location
    Tampa
    MS-Off Ver
    2007
    Posts
    1

    Lightbulb Re: Displaying Last modified date and time of file in a cell

    I stumbled upon this thread not too long ago and it pointed me in the right direction, but I'm not sure it completely answered the question. Basically, you can create your own function using the Visual Basic side of Excel. From there, you can call on the function in any cell you'd like and it will display the modified date of the file. Here's the function:

    Please Login or Register  to view this content.
    I made a quick post about this in my blog with instructions on how to add it, for those of you that may need a full tutorial.

    http://danblee.com/display-modified-date-of-excel-file/

    Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1