CountIf Condition based on lookup in a list of values


E

Eric E

I have a row with input data: cells with values of RED, GREEN, PINK, TAN.
I have a table/range (PRIMARY_COLORS) that includes RED, BLUE, GREEN.
I would like to count the number of valid primary colors are in the input
data row.
I cannot figure out how to include a conditional statement in the COUNTIF
function: i.e., COUNTIF the cell value is a MATCH in the PRIMARY_COLORS range.

Can this be done?

Thanks.
 
Ad

Advertisements

J

Jacob Skaria

Try
=COUNTIF(A:A,"red")

Or if you have A1 = red

=COUNTIF(A:A,A1)


If this post helps click Yes
 
J

Jacob Skaria

The below formula will return the number of primary colors in the array from
Row 1. Adjust the range to suit your requirement..

=SUMPRODUCT(--(ISNUMBER(MATCH(1:1,{"red","blue","green"},0))))

If you are using a named range replace the array with the named range

=SUMPRODUCT(--(ISNUMBER(MATCH(1:1,PRIMARY_COLORS,0))))

If this post helps click Yes
 
E

Eric E

Thanks. The named range formula seems to do exactly what I was looking for.
I am curious as to what the -- indicates in the formula and how it is used.
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Need Countifs Formula Help 0
CountIf with And 0
countif function 4
Wobbled countif and conditional format Results 9
Countif with multiple criteria 5
Countif Function Using "AND" 3
COUNTIF 15
CountIf previous cell formula 0

Top