Count instances of combinations

asad

Well-known Member
Joined
Sep 9, 2008
Messages
1,434
Hello Guys,

I tried but can't get around to work out how to get the combinations of a set of numbers to match up with a range. The data looks like below:
Excel Workbook
DEFGHIJKL
137391141831301
22325275140131
353114403010121
41201728213191
540112815272991
632915244012141
712267373817131
Sheet2


But, I want the formula to check if the numbers in D1:J1 are in a same row then it should be included. They could be in any sequence. D1 could be in E20 but then rest of the numbers from E1:J1 have to be in row 20.

Is it possible or am I just banging head against a brick wall?

Asad
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I tired the following
Code:
=SUMPRODUCT(--(D$1:J$500=D1),--(D$1:J$500=E1),--(D$1:J$500=F1),--(D$1:J$500=G1),--(D$1:J$500=H1),--(D$1:J$500=I1),--(D$1:J$500=J1))

But no success.
 
Upvote 0
If the values in Line 20 did match D1:J1, what are you supposed to see in Column L? Are you looking for the row that has the matching values for D1:J1 or something else?
 
Upvote 0
Thanks for the response.
I just want to know how many times that combination appears in the whole range which extends to 500 rows, and give me the count number for that. So if all numbers in row 1 appear in 3 other rows say row 120, row 290, and row 300, then it should give me 3 as answer.

Asad
 
Upvote 0
Thanks for the response.
I just want to know how many times that combination appears in the whole range which extends to 500 rows, and give me the count number for that. So if all numbers in row 1 appear in 3 other rows say row 120, row 290, and row 300, then it should give me 3 as answer.

Asad
As long as there are no duplicate numbers in any row...

Book1
DEFGHIJ
13739114183130
2232527514013
35311440301012
41141830313739
54011281527299
63291524401214
73937313018141
Sheet1

=SUMPRODUCT(--(MMULT(--(ISNUMBER(MATCH(D2:J7,D1:J1,0))),{1;1;1;1;1;1;1})=7))
 
Upvote 0
With duplicates a possible solution (not elegant) is to use a helper-column, say column X, with this formula in X2 copied down till X500

=COUNTIF(D2:J2,$D$1)>0+COUNTIF(D2:J2,$E$1)>0+.......+COUNTIF(D2:J2,$J$1)>0

and
=COUNTIF($X$2:$X$500,7)

M.
 
Upvote 0
Sorry, i missed the parenthesis...

X2
=(COUNTIF(D2:J2,$D$1)>0)+(COUNTIF(D2:J2,$E$1)>0)+.......+(COUNTIF(D2:J2,$J$1)>0)

M.
 
Upvote 0
Thanks Biff and Marcelo.

Biff's formula does what I wanted and in the manner I wanted. Thanks a lot again.

Asad
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,763
Members
452,940
Latest member
rootytrip

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