Consulting

Results 1 to 3 of 3

Thread: Run macro if date has changed

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    Run macro if date has changed

    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!
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Babydum
    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

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

  3. #3
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    Thanks Mr X - perfect! (As usual.)

    Quote Originally Posted by xld
    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.
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

Posting Permissions

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