Results 1 to 6 of 6

Thread: [RESOLVED] Date Saved

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    448

    Resolved [RESOLVED] Date Saved

    I found this code, and of course I am unable to debug it. It hangs up at the Sheets("Index").range
    I am trying to have a date cell that tells me the last time the workbook was saved, and not (like it is now) where it states right now. I am apparently supposed to put the now() statement in cell A1 of whatever worksheet, and have the Macro copy and paste values only into the cell where I want the last save date. Sounds simple, and I have this piece of code, but it's like trying to write german to me. I just don't have the vocabulary.

    Sub Workbook_Open()

    Sheets("Index").range ("A1") 'Cell where =Now() is
    Selection.Copy
    Active.Sheet.range("AA85").Select ' Target Cell
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False ' PasteSpecial value only

    End Sub

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Date Saved

    try
    Sheets("Index").range ("A1") = ThisWorkbook.BuiltinDocumentProperties("last save time")
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    448

    Re: Date Saved

    this did something, but i can't read it. it says this:
    40055.8210648148. How would I change this to a date format?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Date Saved

    format the cell
    range("a1").numberformat = "dd/mm/yyyy"
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2009
    Posts
    448

    Re: Date Saved

    sometimes you just gotta laugh at yourself. ;-)
    That worked.
    How would I go about applying this to the active sheet being saved? Where would I put the code? On the sheet code it's self or in the workbook? right now I have to have a button assigned to it.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Date Saved

    workbook open event, is probably the best will update the last saved time when the workbook is opened, specify the the range with sheet name
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width