ExcelBanter

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

nospam

countif OR function
 
Hi

I am using the following formula to calculate the number of males and
females in my class lists.

It works well.

COUNTIF(D3:D28,"M")

COUNTIF(D3:D28,"F")


I want to count the total number of Males and Females, I am currently
using a a sum function on the range but is it possible to use an OR
expression inside a function?

Basically what I was looking for was a version of what follows (that
works!)


COUNTIF(D3:D28,"M" or "F")

so if there were 5 males and 7 females it would return the value 12.

this is more for my own education than anything else.

Thanks


Biff

Hi!

Try one of these:

=COUNTIF(D3:D28,"M")+COUNTIF(D3:D28,"F")

=SUMPRODUCT(--(D3:D28="M")+(D3:D28="F"))

Biff

"nospam" wrote in message
...
Hi

I am using the following formula to calculate the number of males and
females in my class lists.

It works well.

COUNTIF(D3:D28,"M")

COUNTIF(D3:D28,"F")


I want to count the total number of Males and Females, I am currently
using a a sum function on the range but is it possible to use an OR
expression inside a function?

Basically what I was looking for was a version of what follows (that
works!)


COUNTIF(D3:D28,"M" or "F")

so if there were 5 males and 7 females it would return the value 12.

this is more for my own education than anything else.

Thanks




Dave Peterson

You could use:
=SUM(COUNTIF(D3:D28,{"M","F"}))

or just
=COUNTIF(D3:D28,"M") + COUNTIF(D3:D28,"F")
(in one cell)


nospam wrote:

Hi

I am using the following formula to calculate the number of males and
females in my class lists.

It works well.

COUNTIF(D3:D28,"M")

COUNTIF(D3:D28,"F")

I want to count the total number of Males and Females, I am currently
using a a sum function on the range but is it possible to use an OR
expression inside a function?

Basically what I was looking for was a version of what follows (that
works!)

COUNTIF(D3:D28,"M" or "F")

so if there were 5 males and 7 females it would return the value 12.

this is more for my own education than anything else.

Thanks


--

Dave Peterson

David Billigmeier

=SUMPRODUCT((D3:D28="M")+(D3:D28="F"))
--
Regards,
Dave


"nospam" wrote:

Hi

I am using the following formula to calculate the number of males and
females in my class lists.

It works well.

COUNTIF(D3:D28,"M")

COUNTIF(D3:D28,"F")


I want to count the total number of Males and Females, I am currently
using a a sum function on the range but is it possible to use an OR
expression inside a function?

Basically what I was looking for was a version of what follows (that
works!)


COUNTIF(D3:D28,"M" or "F")

so if there were 5 males and 7 females it would return the value 12.

this is more for my own education than anything else.

Thanks



nospam

Thanks everyone

that's great.




Dave Peterson writes
You could use:
=SUM(COUNTIF(D3:D28,{"M","F"}))

or just
=COUNTIF(D3:D28,"M") + COUNTIF(D3:D28,"F")
(in one cell)


nospam wrote:

Hi

I am using the following formula to calculate the number of males and
females in my class lists.

It works well.

COUNTIF(D3:D28,"M")

COUNTIF(D3:D28,"F")

I want to count the total number of Males and Females, I am currently
using a a sum function on the range but is it possible to use an OR
expression inside a function?

Basically what I was looking for was a version of what follows (that
works!)

COUNTIF(D3:D28,"M" or "F")

so if there were 5 males and 7 females it would return the value 12.

this is more for my own education than anything else.

Thanks




Jerry W. Lewis

Biff wrote:

....

=SUMPRODUCT(--(D3:D28="M")+(D3:D28="F"))


-- is redundant, because the addition coerces both logical arrays to
numbers.

Jerry



All times are GMT +1. The time now is 03:12 PM.

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