HolaGonzalo
HolaGonzalo

Reputation: 345

Excel: "countif" or "if count"

I'm trying to compare two rows: C17:X17 with C10:X10

If C17:Z17>C10:Z10, then count the number of instances.

I've tried =IF(C17:X17>C10:X10,COUNT(C17:X17),0) and I've also tried =COUNTIF(C17:X17,C17:X17>C10:X10)

Any help? Thanks!

enter image description here

Upvotes: 0

Views: 100

Answers (2)

Mark
Mark

Reputation: 4537

Given that you want to compare two 'vectors' and you can't make a new 'vector' with a formula, you might want to consider VBA as an option.

Using this answer as a starting point we can see some VBA for looping of rows:

Dim x As Integer
x=0
For i = 3 to 26
    If Sheet.Cells(i, 17).Value > Sheet.Cells(i,10).Value
        x=x+1
    End If
Next
Sheet.Range("D1").Value = x

Here, all you need to do is change the cell referenced on the last line to where you want the count to go.

Upvotes: 0

barry houdini
barry houdini

Reputation: 46371

Try using SUMPRODUCT like this:

=SUMPRODUCT((C17:Z17>C$10:Z$10)+0)

I made the row 10 reference absolute - then you can copy down and that part won't change

Upvotes: 2

Related Questions