Need help with Micro in excel

curo

Master Member
Joined
Jan 1, 2000
Messages
3,049
Reaction score
126
Hi, I'm trying to create a cell that will display the last saved date of the worksheet automatically.

I did a google search and found this code:

Function LastSaved() As Date
Application.Volatile
LastSaved = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function

But the problem now is when I formatted the cell to display date, the date is incorrect. It show year 2017 and date is next day. So its like showing the future. Anyone know how can I correct this problem so show tat it is today date?

Thanks
 

ctingyee

Junior Member
Joined
Jun 3, 2011
Messages
90
Reaction score
0
Can you check your computer's time (just mouse over the clock)? Maybe it is showing the date you saw or you forgot to change the time back while using function.

I used the function in module shows date is okay.
 

curo

Master Member
Joined
Jan 1, 2000
Messages
3,049
Reaction score
126
Can you check your computer's time (just mouse over the clock)? Maybe it is showing the date you saw or you forgot to change the time back while using function.

I used the function in module shows date is okay.

I checked. My computer time and year is correct. Time also correct. That is why I am stuck..
 

ctingyee

Junior Member
Joined
Jun 3, 2011
Messages
90
Reaction score
0
I checked. My computer time and year is correct. Time also correct. That is why I am stuck..

Okay... How about that excel file. Can you check it at explorer? If the file last saved on 'future' date, I think is correct.

Haven't you edited the file, saved it, closed and reopen the file to check the result?
 

curo

Master Member
Joined
Jan 1, 2000
Messages
3,049
Reaction score
126
Okay... How about that excel file. Can you check it at explorer? If the file last saved on 'future' date, I think is correct.

Haven't you edited the file, saved it, closed and reopen the file to check the result?

i even tried the formula =date(). It show the correct date and year. I redo the micro but same problem. (edited, save, close and reopen)
 

ctingyee

Junior Member
Joined
Jun 3, 2011
Messages
90
Reaction score
0
Interesting. I used Excel 2010, new macro-enable excel file. Looks fine to me.

If I saved today, I get the value 41508.49111 in number. Before you set to date format, what's the value?

i even tried the formula =date(). It show the correct date and year. I redo the micro but same problem. (edited, save, close and reopen)
 

curo

Master Member
Joined
Jan 1, 2000
Messages
3,049
Reaction score
126
Interesting. I used Excel 2010, new macro-enable excel file. Looks fine to me.

If I saved today, I get the value 41508.49111 in number. Before you set to date format, what's the value?

I got 41508.47159.

So different from yours
 

ctingyee

Junior Member
Joined
Jun 3, 2011
Messages
90
Reaction score
0
That value is correct, 41508 means today date (2013/08/22) and the floating value is the time.

If you format date on cell that value 1.99999 should be 1900/01/01 23:59:59

I don't know why your 41508 refers to year 2017.

...

You use office mac version?
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top