I have the following code and want the MsgBox ("Error. Please input a valid Starting Position.") to show if there is error in x=step, and want the MsgBox ("task completed.") to show if no error in x= step.
How can I code it? Thank you!!!
Sub Historical()
On Error GoTo Errormask
x = Application.WorksheetFunction _
.Match(Cells(107, 2).Value, Range("A1:A374"), 0)
'error happens on this step.'
Errormask:
MsgBox ("Error. Please input a valid Starting Position.")
"this part is the VBA procedure i need if not error''
MsgBox ("task completed.")
End Sub
How can I code it? Thank you!!!
Sub Historical()
On Error GoTo Errormask
x = Application.WorksheetFunction _
.Match(Cells(107, 2).Value, Range("A1:A374"), 0)
'error happens on this step.'
Errormask:
MsgBox ("Error. Please input a valid Starting Position.")
"this part is the VBA procedure i need if not error''
MsgBox ("task completed.")
End Sub