V
vbidiot
How do I simplify the code below instead of putting all of the different
strings together? I want it to say if MyStr does not equal 1 or 4 or 7
or 10 then message box appears. I'm doing it the long way...I know
there's a shorter way.
Code:
--------------------
Dim AnyString, MyStr
AnyString = Range("assignment")
MyStr = Right(AnyString, 1)
If MyStr = 2 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 3 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 5 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 6 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 8 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 9 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 11 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 12 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
strings together? I want it to say if MyStr does not equal 1 or 4 or 7
or 10 then message box appears. I'm doing it the long way...I know
there's a shorter way.
Code:
--------------------
Dim AnyString, MyStr
AnyString = Range("assignment")
MyStr = Right(AnyString, 1)
If MyStr = 2 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 3 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 5 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 6 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 8 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 9 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 11 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If
If MyStr = 12 Then
MsgBox ("Assignment number must end with 1,4,7,10,13")
Exit Sub
End If