Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
nospam
 
Posts: n/a
Default 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

  #2   Report Post  
Biff
 
Posts: n/a
Default

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



  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
  #4   Report Post  
David Billigmeier
 
Posts: n/a
Default

=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


  #5   Report Post  
nospam
 
Posts: n/a
Default

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





  #6   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default

Biff wrote:

....

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


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

Jerry

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CountIf function Julie Excel Worksheet Functions 2 June 21st 05 10:27 PM
Excel option to store trendline's coefficients in cells for use Miguel Saldana Charts and Charting in Excel 9 June 20th 05 08:45 PM
COUNTIF and then SUM in Same Function wayne75 Excel Worksheet Functions 1 May 24th 05 11:38 AM
A COUNTIF function Challenge Mr. G. Excel Worksheet Functions 1 April 19th 05 09:04 PM
hOW TO USE THE AND OPERATOR WITH THE COUNTIF FUNCTION Marty Excel Worksheet Functions 1 November 11th 04 09:45 PM


All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"