In a large For Next loop, I have many criteria. If any one of these
criteria is a certain value I want to immediately go to the Next x. How can
I do that:
For x = 1 to 100
Criterion 1
Criterion 2
Criterion 3
Criterion 4
Next x
If, say, Criterion 2 is true, I would like to go immediately to the Next x
without considering Criteria 3 and 4.
try this:
Sub MyLoop()
Dim x As Integer
Dim Criterion1 As Boolean
Dim Criterion2 As Boolean
Dim Criterion3 As Boolean
Dim Criterion4 As Boolean
'Criterion2 = True
For x = 1 To 100
Select Case True
Case Criterion1, Criterion2, Criterion3, Criterion4
MsgBox "someone is true"
End Select
Next x
End Sub
--
Regards
Melanie Breden
- Microsoft MVP für Excel -
http://excel.codebooks.de (Das Excel-VBA Codebook)