MsgBox in Schleife
06.04.2020 16:59:30
Peer
Wo muss ich eine MsgBox im Code einfügen, mit der ich nach Durchlaufen der Schleifen angezeigt werden soll, dass kein Eintrag gefunden wurde, ohne in eine Endlosschleife zu gelangen.
For iRowA = 2 To Cells(Rows.Count, 1).End(xlUp).Row
For iRowB = iRowA + 1 To Cells(Rows.Count, 1).End(xlUp).Row
For iCol = 1 To 3
If Cells(iRowA, iCol).Value Cells(iRowB, iCol).Value Then
bln = True
MsgBox "Keinen Eintrag gefunden"
Exit For
End If
Next iCol
If Not bln Then
If Not blnColor Then
iColor = iColor + 1
End If
If Cells(iRowB, 1).Interior.ColorIndex = xlColorIndexNone Then
If Cells(iRowA, 1).Interior.ColorIndex = xlColorIndexNone Then
With Worksheets("Doppelt")
iRowC = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Range(.Cells(iRowC, 1), .Cells(iRowC, 4)).Value = _
Range(Cells(iRowB, 1), Cells(iRowB, 4)).Value
End With
End If
Range(Cells(iRowA, 1), Cells(iRowA, 3)). _
Interior.ColorIndex = iColor
Range(Cells(iRowB, 1), Cells(iRowB, 3)). _
Interior.ColorIndex = iColor
blnColor = True
End If
End If
bln = False
Next iRowB
blnColor = False
Next iRowA
End Sub
Bestimmt hat jemand einen Rat für mich?
LG
Peer
Anzeige