View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rowan Drummond
 
Posts: n/a
Default Comparing input to numerous values

Maybe like this:

Dim ans As String
ans = InputBox("Enter Letter")
Select Case ans
Case "A", "B", "C", "D"
'do whatever
Case Else
MsgBox "Incorrect Input"
End Select

Hope this helps
Rowan

mjack003 wrote:
Howdy,

Is there a simple way in VBA to compare input from the user to a set
amount of constants? Example: Input box asks for a value, then I need
to compare that value to A,B,C,D. If the input does not equal one of
the four then an error msg pops up. Would rather not write four if
then statements.

Thanks in advance,

Mjack