Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50057

Inputbox error message. Formula you typed contains an error.

$
0
0
I have procedure that prompts the user to input a date into an input box. The issue is if the user clicks 'OK' without entering any data into the input box, the user receives popup message of "Formula you typed contains an error." Is there a line of code I could use so this error does not popup? Instead, I would like the message to say something like "date invalid, would you like to try again". thanks

Code:

        'starting date
        sDate = Application.InputBox(vbLf & "Please enter start date:" & vbLf & vbLf & _
            "Enter date in mm/dd/yyyy format." & vbLf & " ", "Starting Date", Type:=1)
            If sDate = 0 Then
                ErrIndicator = 1
                ErrMessage = "User cancelled operation.  No report generated."
                Exit Sub  'User canceled
            End If
       
            If Not IsDate(sDate) Then GoTo InvalidStartDate


Viewing all articles
Browse latest Browse all 50057

Trending Articles