application.worksheet.function 计算列中的单元格数大于另一个

application.worksheet.function that Count the number of cells in columns greater than another

我需要你的帮助!如果其中一列为零,则如何计算 E 列中大于或等于 f 列的单元格的条件 no count

A       |   B   |   C   |   D   |   E   |   F
--------+-------+-------+-------+-------+--------
A1021   |   A10 |   A   |   RX1 |   99  |   98 '-------> 1'
A1021   |   A10 |   A   |   RX1 |   0   |   98
A1021   |   A10 |   A   |   RX1 |   99  |   98
A1021   |   A10 |   A   |   RX1 |   99  |   0
A1021   |   A10 |   A   |   RX1 |   98  |   98 '------> 1'

答案是 2

'First variant
'========================================================================
    Sub test()
    Dim N As Long, LastRow As Long, ocell As Range
    N = 0
    LastRow = Cells(Rows.Count, 5).End(xlUp).Row
    For Each ocell In ActiveSheet.Range("E1:E" & LastRow)
        If ocell.Value >= ocell.Offset(, 1).Value And _
            ocell.Value > 0 And ocell.Offset(, 1).Value > 0 Then
        N = N + 1
        End If
    Next
    MsgBox N
    End Sub
'Second variant
'========================================================================
    Sub test2()
    Dim v As Long
    v = Evaluate("sumproduct((E:E>=F:F)*(E:E>0)*(F:F>0))")
    MsgBox v
    End Sub