
May 29th, 2003, 03:24 AM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
If Else Statement Error
I have an input box where a user inserts a contract reference. This then is used by Excel to do various actions.
What I want to be able to do is include an 'else' so that if the user inserts an invalid reference the resulting '#N/A' error doesn't give me a 'Runtime Error 13'.
I am guessing that I need to put an else Iserror code in somehow but since this is the first bit of VB I have ever written without using the record macro button in Excel I'm a bit stumped.
Code so far is as follows:
Sub Selection()
crit = Inputbox("Please Enter a Contract Reference Number:", "Enter Contract Reference")
Range("B5").Select
Range("B5") = crit
If Range("C13") = "S/O" Then
MsgBox prompt:="Warning! This is a Scheduled Order. Please ensure you have input the Contract Reference correctly.", Buttons:=vbOKOnly + vbCritical, Title:="WARNING!"
' I am guessing my else iserror part should be in here...
End If
End Sub
Thanks in advance.
|