ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   countif, multiple value range PLEASE HELP (https://www.excelbanter.com/excel-discussion-misc-queries/214109-countif-multiple-value-range-please-help.html)

laandmc

countif, multiple value range PLEASE HELP
 
I have a set of data where I want to count some values with a range of
different outcomes:

a b c d
a a c e

0 = COUNTIF(A2:D2,OR(A1,B1,C1,D1))
3 <-- Answer I want to get

The Bottom answer is what I want to get
The Top answe is what I am getting

Is there a way of doing this without doing a long formula such as:
= COUNTIF(A2:D2,A1)+COUNTIF(A2:D2,B1)+COUNTIF(A2:D2, C1)+COUNTIF(A2:D2,D1)

My formula is already very complicated so I want to avoid doing this if
possible

Pete_UK

countif, multiple value range PLEASE HELP
 
This is slightly shorter:

=SUMPRODUCT((A2:D2=A1)+(A2:D2=B1)+(A2:D2=C1)+(A2:D 2=D1))

Hope this helps.

Pete

On Dec 18, 2:33*pm, laandmc wrote:
I have a set of data where I want to count some values with a range of
different outcomes:

a * * * b * * * c * * * d
a * * * a * * * c * * * e

0 * * * = * * * COUNTIF(A2:D2,OR(A1,B1,C1,D1)) *
3 * * * <-- *Answer I want to get * *

The Bottom answer is what I want to get
The Top answe is what I am getting

Is there a way of doing this without doing a long formula such as:
= COUNTIF(A2:D2,A1)+COUNTIF(A2:D2,B1)+COUNTIF(A2:D2, C1)+COUNTIF(A2:D2,D1)

My formula is already very complicated so I want to avoid doing this if
possible



Herbert Seidenberg

countif, multiple value range PLEASE HELP
 
=SUMPRODUCT(COUNTIF(RangeB,RangeA))


All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com