ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   CountIf Function (https://www.excelbanter.com/excel-worksheet-functions/24745-countif-function.html)

David Harrison

CountIf Function
 
HI there

I have a current count IF function that works well. until now.

The range is D4:D9,

Usually it only searches numbers but now i need it to search 8a and 8b as
values. Not the cells.

What is the way around this.

It would be more preferable to seach and add up 8a and 8a as values. (not
the cells 8a and 8b)

Thanks

David

Leo Heuser

Hi David

One way:

=COUNTIF(D4:D9,"8a")

and for counting the numbers of 8a AND 8b

=SUMPRODUCT(COUNTIF(D4:D9,{"8a,"8b"}"))


--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"David Harrison" skrev i en
meddelelse ...
HI there

I have a current count IF function that works well. until now.

The range is D4:D9,

Usually it only searches numbers but now i need it to search 8a and 8b as
values. Not the cells.

What is the way around this.

It would be more preferable to seach and add up 8a and 8a as values. (not
the cells 8a and 8b)

Thanks

David




Bob Phillips


"Leo Heuser" wrote in message
...


and for counting the numbers of 8a AND 8b

=SUMPRODUCT(COUNTIF(D4:D9,{"8a,"8b"}"))


Typos apart, why introduce a nested function call?

=SUMPRODUCT(--(D4:D9={"8a","8b"}))



Leo Heuser

"Bob Phillips" skrev i en meddelelse
...

"Leo Heuser" wrote in message
...


and for counting the numbers of 8a AND 8b

=SUMPRODUCT(COUNTIF(D4:D9,{"8a,"8b"}"))


Typos apart, why introduce a nested function call?


Good question! I guess, I was caught by the subject line.

How on earth did that quotation mark land after "}" instead of after "a" :-)




Leo Heuser

Hi Bob

The expression

--(D4:D9={"8a","8b"})

returns a 2-dimensional (6 x 2) array

where

COUNTIF(D4:D9,{"8a,"8b"}")

returns a 1-dimensional (1 x 2) array

Either one might be useful depending on, which
functions are to be used on them.

To get the sum, either one may be used, and my
solution may be less memory hungry than yours,
depending on how Excel treats the functions internally.
OTOH it uses one more function call.


LeoH


"Bob Phillips" skrev i en meddelelse
...

"Leo Heuser" wrote in message
...


and for counting the numbers of 8a AND 8b

=SUMPRODUCT(COUNTIF(D4:D9,{"8a,"8b"}"))


Typos apart, why introduce a nested function call?

=SUMPRODUCT(--(D4:D9={"8a","8b"}))






All times are GMT +1. The time now is 02:04 AM.

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