Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default EXCEL multiple criteria in countif function

is it possible to have two criteria for a countif
statement like (COUNTIF(A1:A100,=2))or(COUNTIF
(A1:A100,"*2*"))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default EXCEL multiple criteria in countif function

Hi Robert,

This should be all you need

=SUMPRODUCT(--(ISNUMBER(FIND("2",A1:A100))))
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert" wrote in message
...
is it possible to have two criteria for a countif
statement like (COUNTIF(A1:A100,=2))or(COUNTIF
(A1:A100,"*2*"))



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default EXCEL multiple criteria in countif function

For two or more criteria, you can use SUMPRODUCT instead of COUNTIF

=SUMPRODUCT((A1:A1000=2)*(A1:A100,"*2*")

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default EXCEL multiple criteria in countif function

That won't work as the syntax is wrong ("*2*"), and it is an AND not OR
test. What is closest is

=SUMPRODUCT((A1:A100=2)+(ISNUMBER(FIND("2",A1:A100 ))))

but this counts a single 2 twice, so all you need is

=SUMPRODUCT(--(ISNUMBER(FIND("2",A1:A100))))

as I gave previously.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"shades " wrote in message
...
For two or more criteria, you can use SUMPRODUCT instead of COUNTIF

=SUMPRODUCT((A1:A1000=2)*(A1:A100,"*2*"))


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default EXCEL multiple criteria in countif function

"Bob Phillips" wrote...
That won't work as the syntax is wrong ("*2*"), and it is an AND not OR
test. What is closest is

=SUMPRODUCT((A1:A100=2)+(ISNUMBER(FIND("2",A1:A10 0))))

but this counts a single 2 twice, so all you need is

=SUMPRODUCT(--(ISNUMBER(FIND("2",A1:A100))))

as I gave previously.

...

If the last formula works, so would

=COUNTIF(A1:A100,"*2*")

no?

--
To top-post is human, to bottom-post and snip is sublime.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default EXCEL multiple criteria in countif function

Harlan,

Seemingly yes, but it doesn't catch a singleton 2.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Harlan Grove" wrote in message
...
"Bob Phillips" wrote...
That won't work as the syntax is wrong ("*2*"), and it is an AND not OR
test. What is closest is

=SUMPRODUCT((A1:A100=2)+(ISNUMBER(FIND("2",A1:A10 0))))

but this counts a single 2 twice, so all you need is

=SUMPRODUCT(--(ISNUMBER(FIND("2",A1:A100))))

as I gave previously.

..

If the last formula works, so would

=COUNTIF(A1:A100,"*2*")

no?

--
To top-post is human, to bottom-post and snip is sublime.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default EXCEL multiple criteria in countif function

"Bob Phillips" wrote...
Harlan,

Seemingly yes, but it doesn't catch a singleton 2.

....

Actually it'd catch "2", but it only works with cells containing text. It
fails on any numbers. So another alternative

=SUMPRODUCT(--(SUBSTITUTE(A1:A100,"2","")=A1:A100&""))

which is unlikely to be as efficient as your formula, but only uses one
level of function call nesting.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default EXCEL multiple criteria in countif function

I thnk what you need is the OR function nested within the COUNTIF function:

(COUNTIF(OR(condition1,condition2))


HTH

Chris
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default EXCEL multiple criteria in countif function

"ChrisJForeman" wrote...
I thnk what you need is the OR function nested within the COUNTIF function:

(COUNTIF(OR(condition1,condition2))


Won't work. Try it.

--
To top-post is human, to bottom-post and snip is sublime.
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 for multiple criteria yorkshirelass Excel Worksheet Functions 8 June 18th 09 01:45 PM
Countif Function w/ multiple Criteria LaTanya Excel Worksheet Functions 2 November 13th 08 09:42 PM
Using the CountIf function with multiple criteria? Jonathan Excel Worksheet Functions 11 January 9th 08 06:34 PM
COUNTIF or SUM function (Multiple criteria) HELP!! Australia Excel Worksheet Functions 3 September 19th 05 07:39 AM
countif function with multiple criteria Geoff Excel Discussion (Misc queries) 1 August 11th 05 11:50 PM


All times are GMT +1. The time now is 05:46 PM.

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

About Us

"It's about Microsoft Excel"