Count how many sequence numbers

chriscorpion786

Board Regular
Joined
Apr 3, 2011
Messages
108
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I need a formula to count the sequence of numbers from Product A to Product G, I have done it manually, but if I have thousands of rows, i need a formula to do this.

Product AProduct BProduct CProduct DProduct EProduct Fproduct GSerial number sequence (Counted Max one)
125,666125,667155565575585594
4506666676686696708885
33356647512398710090
1001011021031041051067
9899100999831323
565788871011123
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This should do it
Book2
ABCDEFGH
1Product AProduct BProduct CProduct DProduct EProduct Fproduct GMax Sequence
2125666125667155565575585594
34506666676686696708885
433356647512398710090
51001011021031041051067
69899100999831323
7565788871011123
Sheet4
Cell Formulas
RangeFormula
H2:H7H2=IFERROR(1/(1/MAX(FREQUENCY(IF((A2:F2+1)=B2:G2,COLUMN(A2:F2)),IF((A2:F2+1)<>B2:G2,COLUMN(A2:F2)))))+1,0)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
The first 'IF' creates an array of column numbers (column A =1, column B =2, etc) where the number in any given column is 1 greater than the number in the previous column. The second 'IF' returns the column numbers that are not in the first array by using a not equal logical test instead of an equal test. These arrays are used to create the data array and bins array for the frequency function (see excel help for more on this function).

Max returns the largest bin from the array, which is the count of the longest sequence of consecutive numbers. Due to the way that the formula works, the result will be 1 less than the actual count, so 1 is added at the end, but because a result of 1 would be incorrect when there are no consecutive sequence numbers, division by 0 is used to create an error and eliminate these rows before the 1 is added and the final result is shown in the cell.
 
Upvote 0

Forum statistics

Threads
1,214,544
Messages
6,120,126
Members
448,947
Latest member
test111

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