Consulting

Results 1 to 6 of 6

Thread: Macro to compare date in cell to current date.

  1. #1

    Macro to compare date in cell to current date.

    Hi,
    In cell (A1) "Report Date:18-10-2015" Category General as data is from text file.
    Macro to check this date with system date if wrong then alert message of wrong date.
    Any help would be greatly appreciated!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Sub blah()
    y = Split(Split(Range("A1").Value, ":")(1), "-")
    If DateValue(Join(Array(y(2), y(1), y(0)), "-")) = Date Then
      MsgBox "It IS today"
    Else
      MsgBox "It's not today!"
    End If
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Why the double Split?

    Wouldn't this work?
    Sub blue() 
        y = Split(Range("A1").Value, ":")
        If DateValue(y(1)) = Date Then 
            MsgBox "It IS today" 
        Else 
            MsgBox "It's not today!" 
        End If 
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    Hi,

    Thank you P45cal and SamT.

  5. #5
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Quote Originally Posted by SamT View Post
    Why the double Split?
    Because of a recent conversation (with you!) at http://www.vbaexpress.com/forum/show...l=1#post332203

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    DOH! How soon we (I) forget. Nice "universal" solution.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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