Share via

Nested OR in countif function

Anonymous
2013-04-21T17:24:03+00:00

forum members

I am trying to use a nested OR in the countif function as follows:  countif(b8:b500, OR("NOB/PBL", "OOB/PBL", "OBL/PBL")).  It works ok with just one of the items e.g. countif(b8:b500, "NOB/PBL") but not with the nested OR.  I appreciate any help on this issue. 

Lemorse

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-04-21T17:45:22+00:00

COUNTIF() functions cannot use an OR() in its criteria but you could substitute with a simple SUMPRODUCT(). Try,

=SUMPRODUCT((B8:B500="NOB/PBL")+(B8:B500="OOB/PBL")+(B8:B500="OBL/PBL"))

... or,

=SUMPRODUCT(--(B8:B500={"NOB/PBL","OOB/PBL","OBL/PBL"}))

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Héctor Miguel 71,595 Reputation points
2013-04-21T17:46:00+00:00

try this way:

=sumproduct(countif(b8:b500,{"nob/pbl";"oob/pbl";"obl/pbl"}))

or...

=sumproduct(countif(b8:b500,{"nob";"oob";"obl"}&"/pbl"))

hth,

hector.

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-04-22T15:59:06+00:00

    To you who replied:

    Thank you all for your suggestions.  I tried them and they all worked and I learned a new function.  This forum and you guys that contribute to it never fail to amaze me and I want you to know that here is one person who really appreciates the contribution you make.  Thank you.

    Lemorse

    Was this answer helpful?

    0 comments No comments
  2. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2013-04-21T22:56:16+00:00

    Hi,

    Try this

    =SUMPRODUCT(1*(ISNUMBER(MATCH($B$8:$B$500,$A$1:$A$3,0))))

    Hope this helps.

    Was this answer helpful?

    0 comments No comments