Count how many times in total two values appear together in a row for all the rows

Dainer

New Member
Joined
Dec 25, 2017
Messages
5
Hello

The title may be confusing to understand but here is an example of what I need to achieve.

[TABLE="class: grid, width: 150"]
<tbody>[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]6[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]9[/TD]
[/TR]
</tbody>[/TABLE]

I would like to know a formula, that counts the rows where number "5" appears together with number "6" in the entire table and outputs how many of those rows are in total.

On the example table we can see that "5" and "6" appear together in 4 rows, so output = 4

Thank you in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If "5 and 6 appear together" means "5 and 6 in this very order in adjacent cells in the same row," then try the following array formula:

=SUM(--(MMULT((A1:E5=5)*(B1:F5=6),{1;1;1;1;1})>0))

If "5 and 6 appear together" means "5 and 6 anywhere in the same row," then try the following array formula:

=SUM((MMULT(--(A1:E5=5),{1;1;1;1;1})>0)*(MMULT(--(A1:E5=6),{1;1;1;1;1})>0))

Note: these array formulas should be entered using Ctrl+Shift+Enter, not just Enter.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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