|
-
Aug 28th, 2009, 10:22 PM
#1
Thread Starter
Hyperactive Member
[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
-
Aug 28th, 2009, 10:31 PM
#2
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
-
Aug 30th, 2009, 06:45 PM
#3
Thread Starter
Hyperactive Member
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?
-
Aug 30th, 2009, 10:13 PM
#4
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
-
Aug 31st, 2009, 10:50 AM
#5
Thread Starter
Hyperactive Member
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.
-
Aug 31st, 2009, 04:33 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|