Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping problem

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrolling Looping Problem Nick Wakeham Excel Discussion (Misc queries) 0 June 12th 07 01:42 PM
Macro looping problem. [email protected] Excel Discussion (Misc queries) 8 October 26th 06 02:44 PM
If Then Else looping problem Kieran1028[_12_] Excel Programming 1 November 11th 04 06:27 PM
complex looping problem Max Bialystock Excel Programming 16 April 10th 04 01:56 PM
Looping Problem Todd Huttenstine[_3_] Excel Programming 5 January 25th 04 12:51 AM


All times are GMT +1. The time now is 03:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"