rais error vba
Sub TestRaiseError() On Error GoTo eh If Range("A1") <> "Fred" Then Err.Raise vbObjectError + 1000, , "The text in the cell A1 should say Fred." End If Exit Sub eh: MsgBox "User Error: " & Err.Description End Sub
Source: www.automateexcel.com