Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use COUNTIF on two columns to compare values?

I have two columns in Excel, like this:

 A   B
0.5  0.4
0.6  0.59
0.1  0.2
0.3  0.29

I want to count how many of the values in B are less than their corresponding values in A. In this case, the answer is 3.

I can do this by adding an extra column, B-A and then doing COUNTIF(RANGE, "<0"), but I am wondering if there's a way to do it without adding an extra column.

I realize this is on the fringes of what one might consider programming, but hopefully it's just on the right side of the line, rather than the wrong side.

like image 892
Ben Avatar asked Feb 05 '09 10:02

Ben


People also ask

Can I use Countif in multiple columns?

You can use the COUNTIFS function in Excel to count cells in a single range with a single condition as well as in multiple ranges with multiple conditions.

Can you have 2 criteria in Countif?

Using COUNTIF with multiple criteria. The best function you can use for situations when you need to count cells based on multiple criteria is the COUNTIFS function. The “s” on the end of Countif makes it plural, and that means that there are multiple criteria.

How do I Countif a cell between two values?

Using COUNTIFS to Count Between two Numbers First, enter the “=COUNTIS(“ in cell C1. After that, refer to the range from where you want to count the values. Next, you need to specify the upper number using greater than and equal sign. From here, again you need to refer to the range of numbers in the criteria2.


1 Answers

Actually this is something I would do with a program.

Create a macro to:

  • insert column C.
  • set range("cN").value to "=bN-aN" for all N where range("aN").value <> "".
  • do your countif calculation and shove it into a cell (not column C).
  • delete column C.

There may be an easier non-programming way but I don't know it (and then your question would be closed anyhow).

like image 153
paxdiablo Avatar answered Sep 30 '22 12:09

paxdiablo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!