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.

12345
23456
34567
45678
56789

<tbody>
</tbody>

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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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