I am attempting to validate a date from an input box with the following code (which does not work and no doubt reveals my lack of vba experience)
The variable "dweekend" is set as a date. What I am trying to accomplish is for the user to have another opportunity to enter the date if what was entered is older than 30 days or greater than today but I don't know how to get the user back to the input box if this occurs. Otherwise the date would be used and the procedure would continue.
Excel 2003 / Windows XP
Thanks for your time
Code:
dweekend = InputBox("Please enter week ending date (mm/dd/yy)", "WeekEnding")
If dweekend.Value < TODAY() - 30 Then GoTo error1
If dweekend.Value > TODAY() Then GoTo error2
End If
error1: MsgBox ("Date is older than 30 days")
error2: MsgBox ("Date is not valid")
The variable "dweekend" is set as a date. What I am trying to accomplish is for the user to have another opportunity to enter the date if what was entered is older than 30 days or greater than today but I don't know how to get the user back to the input box if this occurs. Otherwise the date would be used and the procedure would continue.
Excel 2003 / Windows XP
Thanks for your time