Rank order a sequence of numbers WITHIN A CELL

xmbwd

New Member
Joined
Sep 15, 2006
Messages
5
I have a series of numbers inside a cell that are not in order.
For example:

[33, 22, 2, 9, 1, 45].

Is there any way (other than simply retyping the numbers) to automatically reorder the numbers so that they are listed sequentially??

The result would look like this (again, inside a single cell):

[1, 2, 9, 22, 33, 45]

Although these numbers are in one cell, I have the same issue with thousands of cells, so retyping is not an option.

Thanks so much for any help.
 
Norie -- you totally nailed it. That works perfectly. Thanks so much for the edits. And thanks again to Jindon for getting us started.

In answer to your question, its just a numbered series that was formerly associated with words. I did a global replace to match with a code of numbers. But of course the numbers were out of sequence, hence the need for the code.

Thanks again. So helpful :oops: :oops:
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
xmbwd

Glad to see you got it sorted.

The question about the sort was actually for Jindon.:)

There are various different methods of sorting using code. eg Bubble Sort

I'm not sure which method Jindon is implementing but I think I've seen it somewhere before.

Knowing me it probably is a Bubble Sort, and I'm just not recognizing it as such.:eek:
 
Upvote 0
Jindon

Hope you don't mind me altering your code.:)

By the way what type of sort is that?

I seem to vaguely recognise it from university, but that was a long time ago.

Thanks for the modification and it is based on "QuickSort" algorithm.
 
Upvote 0

Forum statistics

Threads
1,215,990
Messages
6,128,158
Members
449,428
Latest member
d4vew

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