How to define a non continuous range in COUNTIF
As an alternative that would work for copying and pasting, you could do:
=COUNTIF($C$1:$C$15,"B") + COUNTIF(A16,"B")
Here's the formula for cell B16:
=SUM(COUNTIF(INDIRECT({"C1:C15","A16"}),"B"))
For the record, if I understand well, you want to count the value from the cell A16
. But if you do such a formula:
=COUNTIF(C1:C15,A16)
You know you will have the value (here B
) in cell A16
, don't you?
So the value you want to get is:
=COUNTIF(C1:C15,A16) + 1
What did I misunderstand?
You can also declare a named range of non-contiguous ranges, but you must use the INDIRECT function in declaring the range. Otherwise, it will fail just like a normal, non-contiguous range.
Declaring the range ("Range1") should have the "applies to" field read:
=INDIRECT({"A1:B2","C4:F17"})
Or use other named ranges:
=INDIRECT({"Table1[Column1]","Table2[Column3]","Table4[Column2]")
Then you can reference it like:
=COUNTIF(Range1,"=Yes")