If >0, count various codes in a range on another sheet

S

Steve

I have this formula in N37 =SUM(G37:M37)/5
If the above result is >0, I want to count the number of times a specific
code(PQ) is in a specific range on another worksheet, and in cell N38, I'd
like the result to be, if PQ occurs 2 times in that range, 2 PQ. And if not
0, then nothing.

Something like. If N37>0, countif(data!A1:A7*PQ*,"")
So the result in the sample would be 2 PQ
A
s
s
pq
pq
s
s
s

Thanks

Steve
 
B

Basil

Try this formula in N38:
=IF(AND(N37>0,COUNTIF(range,"PQ")=2),"2 PQ","")
replace the word range with the actual range on the other sheet you'll be
looking for PQ in. I've assumed PQ will be on its own in the cells where it
exists.

If you wanted to do the whol elot in cell N37:
=IF(AND(SUM(G37:M37)/5>0,COUNTIF(range,"PQ")=2),"2 PQ","")

Basil
 
S

Steve

I can't get it to work. One thing I see that I may not have been clear on, is
that the formula appears to be using 2 as an absolute. What I meant to
indicate is that the number of times the PQ is in the specific range may be
1,2, 3 any number of times. So I want to count how many times it's in the
range. Such as -
1 PQ, or 2 PQ, or 3 PQ, etc.

Thanks again,
 
B

Basil

Try:
=IF(AND(N37>0,COUNTIF(range,"PQ")>0),COUNTIF(range,"PQ")&"PQ","")

or you can use a variant of what Bob entered with what is above if it still
doesn't work.

B
 
S

Steve

This one worked to give me the # of PQ's. Thanks,

But I tried to add to it &text to get the # of PQ's & the text PQ, but I
couldn't figure it out.

I'd like the result to be 1 PQ

Thanks again,

Steve
 
G

Gord Dibben

=IF(N37>0,COUNTIF(data!A1:A7,"*PQ*"),"") & " PQ"

Or simply custom format to 0 " PQ"


Gord Dibben MS Excel MVP
 

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

Top