Count groups of text with multiple ranges

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
6,336
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Count groups of text with multiple ranges

With range A3:P3 how many groups of three
(any order) occur?
Example Apple Carrot Orange =1

I put the criteria in a range A12:A14 and named it rI. The criteria are Apples, Oranges, Carrots.

=(SUM(IF(COUNTIF(A3:C3,rI)=1,1,0))=3)*1 gives result for first group.

What formula will gives the result across the range?

I can get the result with several brute force
methods.
Putting multiple versions of the above (with a3:C3 shifted) is a bit of a monster.


=(SUM(IF(COUNTIF(A3:C3,rI)=1,1,0))=3)*1+(SUM(IF(COUNTIF(B3:D3,rI)=1,1,0))=3)*1 .. etc

Thanks in advance.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Dave,

Condider the following sample

{"Apples","Oranges","Carrots","Oranges","Apples","Carrots","pears","oranges","vegetables","apples","carrots","oranges"}

in A3:L3 (I didn't make it up to P3 :biggrin: ).

The conditions (the target 'unordered' triplet) for which we want a count of occurrences in A3:L3 are in A12:A14, that is,

{"Apples";"Oranges";"Carrots"}.

A12:A14 is named as rl.

In A4 array-enter and copy across as far as needed:

=IF(COUNTA(A3:C3)=3,IF(SUM(1/(COUNTIF(A3:C3,A3:C3)))=3,(COUNT(MATCH(A3:C3,rl,0))=3)+0,0),0)

In A5 enter:

=SUM(A4:L4)

In order to array-enter a formula (I know you know all this), hit control+shift+enter at the same time, not just enter.

Note. I didn't seek to collapse the main formula into a single cell-formula nor looked for such an alternative.

Regards,

Aladin
 
Upvote 0
Aladin

Thanks for the alternative.
It gives the same answer as my formula and it includes one additional factor.

Thank you

At this time, I believe if someone really needs such a feature for a range A3:P?, someone could probably develop a UDF.
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top