View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_5_] Dana DeLouis[_5_] is offline
external usenet poster
 
Posts: 77
Default test for "A" or "D"

I am not sure, but if one enters an invalid character by accident, would you
want them to try again, or exit the Sub by default? As an general idea,
perhaps you could loop until they enter a valid character. Again, just an
thought.

Sub Demo()
Dim S As String
Dim Ok As Boolean
Ok = False

Do
S = UCase(InputBox("Enter A or D (Blank to exit)"))
Select Case S
Case "A", "D"
Ok = True
MsgBox "entry OK"
Case vbNullString
Ok = True
MsgBox "Blank...about to exit sub"
Case Else
Ok = False
MsgBox "Innvalid: Enter A, D, or Blank to exit"
End Select
Loop While Not Ok

If S = vbNullString Then Exit Sub

' Continue with code. S = A or D
'....
End Sub


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"David Turner" wrote in message
...
Myrna Larson wrote

I don't understand what you mean by "split my code". How does the
Select Case block differ from an If/End if block in this situation?


All code following a valid Column entry would take the place of Chip's
MsgBox "entry OK" and the Case Else would follow that. Not True?

If Not (S = "A" or S = "D") Then


I like it.

Thanks for jumping in.

--
David