Sort data according to largest groupings of consecutive numbers

lwhyatt

New Member
Joined
May 26, 2010
Messages
33
Is it possible to sort a column of data into groups of conecutive numbers and then sort said groups into descending size order?

eg
1
2
3
4 (4 consecutive)
99
101
102
103
104
105
106
107 (7 consecutive)
200
210
211
212
213
214
215
216
217 (8 consecutive)

becomes...

210
211
212
213
214
215
216
217

101
102
103
104
105
106
107

1
2
3
4

99
200
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
sorry should read Is it possible to sort a column of data into groups of consecutive numbers and then sort said groups into descending size order?
 
Upvote 0
So this tests if numbers are consecutive:

=IF(A2-A1=1,"C",0)

1669932320644.png


Trouble is, it only highlights the second entry in a consecutive list ( no C at the start of the run).

I then need to sort column A starting with those that have the largest blocks of C's down to the smalest (1's)
 
Upvote 0
So this tests if numbers are consecutive:

=IF(A2-A1=1,"C",0)

View attachment 80038

Trouble is, it only highlights the second entry in a consecutive list ( no C at the start of the run).

I then need to sort column A starting with those that have the largest blocks of C's down to the smalest (1's)
This then corrects it

=IF(A3-A2=1,"C",IF(A1-A2=-1,"C",0))

But it also makes out there's bigger blocks if consecutive groups ajoin

eg

333 C
334 C
335 C
1234C
1235C
1236C

makes it look like 6 consecutive numbers when its two groups of three!
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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