#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    4
    Rep 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.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    20
    Rep Power
    0
    You could do something like

    On Error Resume Next

IMN logo majestic logo threadwatch logo seochat tools logo