Link to home
Start Free TrialLog in
Avatar of RWayneH
RWayneHFlag for United States of America

asked on

Is ActiveCell > or < today?

Must be doing something wrg.  Every date I give it is less than today.  Using yyyy-mm-dd format, tried formatting data as ShortDate, General, and others... still can not get this to recognize a date as in the future?  It does not give me a positive number for 9999-12-31?  Any ideas?  Please advise and thanks.

 TargetDate  = ActiveCell.Value 'format?
            Diff = DateDiff("d", Now, TargetDate)
            If Diff < 0 Then
                MsgBox ("Date is in the past, less than today" & Diff)
            ElseIf Diff > 0 Then
                MsgBox ("Date is in the future, greater than today" & Diff)
            End If

Open in new window

Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Are your target cells formatted as date?
Avatar of RWayneH

ASKER

I tried that formatted as ShortDate
Avatar of RWayneH

ASKER

Tried it again and it worked.  arg.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RWayneH

ASKER

Yup, had to use: Selection.NumberFormat = "m/d/yyyy"
Is there anything else I can do for you here?
Avatar of RWayneH

ASKER

Thanks
You're welcome.