Hi there,

Is there way to loop back to the top of the If statement from the Else statement?

I'm validating a string (from InputBox) against dozens of conditions, so I've got code through each valid condition using InStr. If the string doesn't match any, it hits the Else statement, which prompts another InputBox linked to the same string saying "You entered an invalid value, please carefully enter... etc." and then the user can try again to enter a correct value. If this condition is triggered, I want to move through the list of conditions again by going back to the top of the If statement and going through again.

Sample code:

Sub ValidateUserData
    Dim MyString As String
    MyString = InputBox ("Please enter value from list below" & vbNewLine & "Cat" & vbNewLine & "Dog" & vbNewLine & "Bird")
    If InStr(MyString, "Cat") <> 0 Then
        MsgBox "Cat"
    ElseIf InStr(MyString, "Dog") <> 0 Then
        MsgBox "Dog"
    ElseIf InStr(MyString, "Bird") <> 0 Then
        MsgBox "Bird"
    Else: MyString = InputBox ("You entered an invalid string: Please enter value from list below" & vbNewLine & "Cat" & vbNewLine & "Dog" & vbNewLine & "Bird")
        'this is where I want to loop back to the start to check that this newly entered string is valid
    End If
End Sub

Elsewhere I've seen people using While statements, but since I'm checking against 26 possible values it seems messy to use "While InStr(MyString, "Bird") = 0 Or InStr(MyString, "Dog") = 0 Or....." etc.

Is there an easier way?
Thanks,
Pango