kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hello everyone here,
I need help to exit a nested loop.
With the inner loops, I have been able to get solutions for how to exit them from this same forum.
But I have added a new loop – the outer one and I can’t seem to figure out how to exit it at the moment and I want the geniuses to help me figure out how to exit the outer loop in case the inner ones are exited successfully.
I need help to exit a nested loop.
With the inner loops, I have been able to get solutions for how to exit them from this same forum.
But I have added a new loop – the outer one and I can’t seem to figure out how to exit it at the moment and I want the geniuses to help me figure out how to exit the outer loop in case the inner ones are exited successfully.
Code:
wStatus = 0
With Application
arr(1) = .Trim(freg2.Text)
V1 = Split(arr(1), " ")
For Each eSheet In Worksheets ‘ How do I exit this loop?
Select Case eSheet.Name
Case “Sheet1”, “Sheet2”, “Sheet3”, “Sheet4”, “Sheet5”
elr = eSheet.Cells(Rows.Count, "B").End(xlUp).Row
If elr < 4 Then elr = 4
For Each sName In eSheet.Range("B4:B" & elr)
If Len(.Trim(arr(1))) = Len(.Trim(sName.Text)) Then
arr(2) = .Trim(sName.Text)
V2 = Split(arr(2), " ")
For i = LBound(V1) To UBound(V1)
For j = LBound(V2) To UBound(V2)
If LCase(V1(i)) = LCase(V2(j)) Then
Matches = Matches + 1
If Matches = UBound(V1) + 1 Then
wStatus = 1
Exit For
End If
End If
Next j
Next i
End If
Matches = 0
Next sName
Case Else
End Select
Next eSheet
End With