How to count consecutive same values in a range of cells

che

New Member
Joined
Jul 15, 2004
Messages
4
I have 100 cells (4 columns by 25 rows) the contents of which are randomly generated to contain either a 1, 2 or 3. The cells are recalculated regularly. I am trying to determine/record the results of the number of times that 3 consecutive 1s, 2s or 3s appear, the number of times that 4 consecutive 1s, 2s or 3s appear....all the way to 20 consecutive appearances of 1s, 2s or 3s--to the extent such a run would be generated. I have tried like to come up with something and nothing seems to work. Also, because the numbers are recalculated, the results need to be tabulated/recorded in another cell before the cells are regenerated. If you can help, I would really appreciate it. Thanks a lot.

CC
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Consecutive across the row or down the columns? Does it count if the last two values in 1 row match the first 2 in the next? Etc...some clarifications could help.
 
Upvote 0
... just curious, what's the formula you're using to generate the random numbers? (excel's "random" numbers aren't very random...)

Are you wanting to have the cells highlighted or just return a number for how many times you have a run of the same number?

Does a 3 in row 25 of column A and a 3 in row 1 of column B count as a match?

Thanks!!

-nate
 
Upvote 0
martinee said:
Consecutive across the row or down the columns? Does it count if the last two values in 1 row match the first 2 in the next? Etc...some clarifications could help.

Sorry, consecutive down the columns and if the final cell in column 1 matches the first two cells in column 2 then it would be deemed to count. the numbers appear in cells d4:d28; g4:g28; i4:i28; l4:l28.

thanks
 
Upvote 0
sky_lennard said:
... just curious, what's the formula you're using to generate the random numbers? (excel's "random" numbers aren't very random...)

Are you wanting to have the cells highlighted or just return a number for how many times you have a run of the same number?

Does a 3 in row 25 of column A and a 3 in row 1 of column B count as a match?

Thanks!!

-nate

Nate-

I recognize the shortcomings of excel's random number tools. I used randbetween.

I don't need the cells highlighted, I just want to tabulate the number of times I have a run of the same number, with a run defined as at least 3 in a row.

The answer to you last question is yes.

Thanks for your help!
 
Upvote 0
sky_lennard said:
... just curious, what's the formula you're using to generate the random numbers? (excel's "random" numbers aren't very random...)

Are you wanting to have the cells highlighted or just return a number for how many times you have a run of the same number?

Does a 3 in row 25 of column A and a 3 in row 1 of column B count as a match?

Thanks!!

-nate

Nate-

I recognize the shortcomings of excel's random number tools. I used randbetween.

I don't need the cells highlighted, I just want to tabulate the number of times I have a run of the same number, with a run defined as at least 3 in a row. Ideally, I would have a table off to the side that would have at the top as a heading 3, 4, 5, 6 ....20 and beneath each heading it would count the number of instances that such experience occurred.

The answer to you last question is yes.

Thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,458
Members
448,899
Latest member
maplemeadows

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