+ Reply to Thread
Results 1 to 11 of 11

Last Updated (Date)

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question Last Updated (Date)

    I am trying to write a Macro or VBA and I have no idea what I am doing. I pulled this from a help site:

    Dim LResult As Date

    LResult = FileDateTime("C:\instructions.doc")

    It is for a workbook. The workbook has a forecast summary page and the objective is to have a data automatically update when the workbook opens to show the Last Modified Date

    I know how to open the Visual Basic Editor and go to the Properties for Sheet1, but that is it.

    I need the updated date to appear on the spreadsheet. Thanks.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Last Updated (Date)

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Last Updated (Date)

    Please put your code in CODE tags, per the forum rules.

    But since this is your first post, and I'm also a Houstonian, I'll give you an answer.

    This actually belongs in "ThisWorkbook" object in the VBA editor, not sheet1, as you suggested. Also, change "A1" to whatever cell you want the date in.

    Please Login or Register  to view this content.
    if you want a certain format on the date, you can use this, just change the format to whatever you want"

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Last Updated (Date)

    Inserted the code as I think you were suggesting - way over my head here. thank you for helping fellow Texas. I still don't understand what I did wrong in my initial request. Please advise.

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Last Updated (Date)

    TRy:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Last Updated (Date)

    I get the error, Compile error: Invalid outside procedure

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Last Updated (Date)

    You have a lot of loose code all over the workbook. You need to get rid of any line of code not between Sub and End Sub lines.

  8. #8
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Last Updated (Date)

    I removed all the junk code and recreated (or copied pasted) the correct code. I am not getting an error now, but after saving and reopening it, it is not changing the Last Updated Date. I did make a change in it before I saved it.

  9. #9
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Last Updated (Date)

    Hmm, worked for me. Will play with it tomorrow.

  10. #10
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Last Updated (Date)

    Thank you very much.

  11. #11
    Registered User
    Join Date
    08-11-2011
    Location
    Houston, TX
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Last Updated (Date)

    I finally got this to work:

    Sub ThisWorkbook_Open()
    Dim LResult As Date
    LResult = FileDateTime("C:\Documents\AccountManagerForecastPetrobras.xlsm")
    Sheet1.Range("C3:D3").Value = LResult
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to get last updated date of a record
    By kmohit in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 06-15-2014, 04:13 AM
  2. Macro to append a date to an existing cell if date is updated
    By brigitteMogg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2013, 10:04 AM
  3. How can date be updated automatically if........?
    By estib52 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-29-2012, 08:17 AM
  4. Add date a row was last updated in last column of row
    By dummy101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2012, 09:40 AM
  5. Date stamp when doc is updated
    By wind1star in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-29-2009, 05:00 PM
  6. Date a worksheet was last updated
    By kenelder in forum Excel General
    Replies: 7
    Last Post: 12-16-2008, 06:15 PM
  7. Date last saved/updated
    By Hal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2006, 03:35 PM

Tags for this Thread

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