Hi Raymond, assume the 2 columns are "A" and "B" following code will pop-up the result in message box:
Sub test()
Dim rng As Range
Dim prevNum As Integer: prevNum = 1
Dim cnt As Integer: cnt = 0
For Each rng In Range("A1:A8")
If Cells(rng.Row, "B").Value = 1 Then
If Cells(rng.Row, "A").Value < prevNum Then
cnt = cnt + 1
End If
prevNum = Cells(rng.Row, "A").Value
End If
Next rng
MsgBox cnt
End Sub
_______________________________________________________________________________________________________________________________
1. Click on the * Add Reputation if you think someone helped you
2. Mark your thread as SOLVED when question is resolved
Alvin
Bookmarks