[英]Excel: “countif” or “if count”
I'm trying to compare two rows: C17:X17 with C10:X10 我正在尝试比较两行:C17:X17与C10:X10
If C17:Z17>C10:Z10, then count the number of instances. 如果C17:Z17> C10:Z10,则计算实例数。
I've tried =IF(C17:X17>C10:X10,COUNT(C17:X17),0)
and I've also tried =COUNTIF(C17:X17,C17:X17>C10:X10)
我已经尝试过=IF(C17:X17>C10:X10,COUNT(C17:X17),0)
并且我也已经尝试过=COUNTIF(C17:X17,C17:X17>C10:X10)
Any help? 有什么帮助吗? Thanks! 谢谢!
Try using SUMPRODUCT like this: 尝试像这样使用SUMPRODUCT:
=SUMPRODUCT((C17:Z17>C$10:Z$10)+0) = 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 我将第10行的参考设为绝对值-然后您可以复制下来,而该部分将保持不变
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. 假设您要比较两个“向量”,并且无法使用公式创建新的“向量”,则可能需要考虑使用VBA。
Using this answer as a starting point we can see some VBA for looping of rows: 使用此答案作为起点,我们可以看到一些用于行循环的VBA:
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. 在这里,您需要做的就是将最后一行引用的单元格更改为希望计数的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.