General discussion
Thread display: Collapse - |
All Comments
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
VBA DATE FORMAT VALIDATION
Line1:
' Prompt for adjusted service date
On Error GoTo Line87
Sheets("LSL PAY IN LIEU").Select
Range("E10").Select
NUMBERTEXT = Application.InputBox( _
prompt:="ENTER ADJUSTED SERVICE DATE ", _
Title:="Employee's Adjusted Service Date")
Selection.NumberFormat = "d/mm/yyyy"
If NUMBERTEXT = "False" Then GoTo Line84
If (Len(NUMBERTEXT) <> 0) Then
NUMBERDATE = DateValue(NUMBERTEXT)
ActiveCell.FormulaR1C1 = NUMBERDATE
Else: ActiveCell.FormulaR1C1 = ""
End If
This is the script for one of the input boxes.
Line 84 is a message box to tell the user that they have exited the spreadsheet.
Line 87 tells the user that the format of the date is incorrect.
I want to use these lines for all the input boxes when the date format is incorrect (3 digit year code) and go back to the line with the error so the user can erkey in the date.