Breaking out of a DO loop in Excel VBA

E

Eliezer

I have the following code:

Do Until [ ... ]
repName = wrksheet.Cells(currentInputRow, "A")

'does user want to process commissions for this
user?
If
mainForm.repsNames_frame.allOrSome_frame.someReps_rb.Value
= True Then 'if this button is checked, user only wants
some reps
If isDesiredRep(repName) = False Then
'[ CODE NEEDS TO GO HERE TO GO TO NEXT
ITERATION IN DO-UNTIL LOOP ]
End If
Else
'all reps are desired; continue processing
regardless of whom it is
End If
Loop

Please see the point where I commented " [ CODE NEEDS TO
GO HERE ] "... How do I do some sort of continue or break
or something so that if execution hits that line, it will
go to the next iteration in the DO-UNTIL loop?

Thanks,
Eliezer
 
T

Tom Ogilvy

You probably need to redesign you if then structure to facilitate this, but

Do Until [ ... ]
repName = wrksheet.Cells(currentInputRow, "A")

'does user want to process commissions for this
user?
If
mainForm.repsNames_frame.allOrSome_frame.someReps_rb.Value
= True Then 'if this button is checked, user only wants
some reps
If isDesiredRep(repName) = False Then
'[ CODE NEEDS TO GO HERE TO GO TO NEXT
goto Label1
End If
Else
'all reps are desired; continue processing
regardless of whom it is
End If
Label1:
' code that sets the next iteration if necessary
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top