verifying date

M

MacroMan

This should work for you (only fix the line breaks):

'Copy your date into a variable
xDateInQuestion = ActiveCell.FormulaR1C1

'Digitize your date
xDateInQuestion = DateSerial(Year(xDateInQuestion), _
Month(xDateInQuestion), Day(xDateInQuestion))

'Reformat it and compare it to today's date
If Format(xDateInQuestion, "YYYYMMDD") > _
Format(Date, "YYYYMMDD") Then
MsgBox "Future date " & xDateInQuestion
ElseIf Format(xDateInQuestion, "YYYYMMDD") = _
Format(Date, "YYYYMMDD") Then
MsgBox "Today " & xDateInQuestion
Else
MsgBox "Past date " & xDateInQuestion
End If

HTH...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top