Thread
:
Looping problem
View Single Post
#
2
Posted to microsoft.public.excel.programming
Trevor Shuttleworth
external usenet poster
Posts: 1,089
Looping problem
Try:
Sub test()
Dim Q As Integer
Q = 0
chk1 = False
Do Until chk1 = True
Dim z ' <<<<<<
z = InputBox("Input quarter (1, 2, 3, or 4) to run. Default is 1.", ,
"1")
Regards
Trevor
"Sleeping Bear" <Sleeping
wrote in message
...
I have a macro that prompts for the quarter. I ask for 1, 2, 3, or 4 and go
on from that. Even with the message box specifying the desired input, some
users are entering alpha or something else. I'm trying to create a loop
that
will give the user 4 chances to enter correctly and then use the default,
regardless of what the user has entered. I keep getting a type mismatch
error
but when I change the variable to integer, alpha data causes it to stop.
Any
ideas?
Here's the code I have now:
Dim Q As Integer
Q = 0
chk1 = False
Do Until chk1 = True
Dim z As String
z = InputBox("Input quarter (1, 2, 3, or 4) to run. Default is 1.", ,
"1")
If z = 1 Then
qtr = Mar
chk1 = True
End If
If z = 2 Then
qtr = Jun
chk1 = True
End If
If z = 3 Then
qtr = Sep
chk1 = True
End If
If z = 4 Then
qtr = Dec
chk1 = True
End If
If Q 3 Then
MsgBox ("You've had 4 chances. I choose the default of '1' for you.")
qtr = Mar
chk1 = True
End If
Q = Q + 1
Loop
Thanks.
Reply With Quote
Trevor Shuttleworth
View Public Profile
Find all posts by Trevor Shuttleworth