+ Reply to Thread
Results 1 to 4 of 4

Automatically entering today's date when saved.

  1. #1
    Registered User
    Join Date
    09-18-2006
    Posts
    2

    Automatically entering today's date when saved.

    Hello,

    Connundrum.... I want to have a place on my excel worksheet that will display the last date it was saved, not opened, but saved. I went to the forums and found a bit of visual basic, but it doesn't seem to work. Here it is:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Sheets("Stats").Range("P1").Value = Format(Date, "mmm dd yyyy")
    End Sub

    I am runing Excel 2000 and don't have a clue on how to get this to work. Any and all help appreciated.

    -Robert-

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Works for me. The code goes in ThisWorkbook not a module.

    VBA Noob

  3. #3
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by SplatterKat
    Hello,

    Connundrum.... I want to have a place on my excel worksheet that will display the last date it was saved, not opened, but saved. I went to the forums and found a bit of visual basic, but it doesn't seem to work. Here it is:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Sheets("Stats").Range("P1").Value = Format(Date, "mmm dd yyyy")
    End Sub

    I am runing Excel 2000 and don't have a clue on how to get this to work. Any and all help appreciated.

    -Robert-
    Robert,

    As VBA Noob says, it goes in the Workbook.
    (Alt/F11 and select 'ThisWorkbook' in the top left (Project) window (by double-click)
    then paste the code in the main window.)

    You need to change the name "Stats" to your worksheet,
    and change the referenced cell "P1" to the cell of your choice.

    hth
    ---

  4. #4
    Registered User
    Join Date
    09-18-2006
    Posts
    2

    Thanks for the direction.

    Ok.... My noob colors are definitely showing. I did have it in the module and not ThisWorkbook. Now that the change has been made, it works perfectly. Thanks again.

    -Robert-

    One of these days I may actually take an Excel class.... save some time.

+ 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