PDA

View Full Version : Run macro if date has changed



Sir Babydum GBE
01-30-2006, 01:54 AM
Good morning my friends...

I have a spreadsheet in which certain cells need to be automatically cleared once every day.
How do I say using VBA something like the following:

If on opening the sheet the date has changed from the last time it was modified, then do "x". If the date is the same, then do nothing.

I can do the clearing, I just don't know how to ask if a date has changed.

Thanks!

xld
01-30-2006, 02:11 AM
Good morning my friends...

I have a spreadsheet in which certain cells need to be automatically cleared once every day.
How do I say using VBA something like the following:

If on opening the sheet the date has changed from the last time it was modified, then do "x". If the date is the same, then do nothing.

I can do the clearing, I just don't know how to ask if a date has changed.

Thanks!


Good morning sir, long time no hear!

Try something like thois in the ThisWorkbook module


Private Sub Workbook_Open()
If Int(ThisWorkbook.BuiltinDocumentProperties("Last Save Time")) <> Date Then
MsgBox Int(ThisWorkbook.BuiltinDocumentProperties("Last Save Time"))
End If
End Sub

Sir Babydum GBE
01-30-2006, 08:04 AM
Thanks Mr X - perfect! (As usual.)


Good morning sir, long time no hear!
Well world peace has recently been threatened again and I'm finding it increasingly difficult to juggle my responsibilies. ;)