# putting #s in order

#### Fire_Chief

##### Well-known Member
I have some numbers that I put in an array like this:

sub GetNumbers()
range("a1").select
for I = 1 to 10

numbers(I) = activecell
activecell.offset(1,0).select

next I

end sub

Now I want to sort them from highest to lowest.
I have gotten some other code but I don't know how to apply it to my problem and I can't get any other responses.

Thank You

### Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You may want to look here for alternatives: http://en.wikipedia.org/wiki/Sorting_algorithm

bubble sort, the most popular, work like this:

function bubble_sort(list L, number listsize)
loop
has_swapped := 0 //reset flag
for number i from 1 to (listsize - 1)
if L > L[i + 1] //if they are in the wrong order
swap(L, L[i + 1]) //exchange them
has_swapped := 1 //we have swapped at least once, list may not be sorted yet
endif
endfor
//if no swaps were made during this pass, the list has been sorted
if has_swapped = 0
exit
endif
endloop
endfunction

You don't need to do all this selecting. You can work with ranges without selecting anything.

What I wrote is an example.

The numbers I select are all over the spreadsheet.

Is there a way I can select thses cells and sort them without changing where they are on the spreadsheet?

I got it

thank you

FINE: could you post the happy end please ?

or did you use the link ?

Thank you

Replies
4
Views
168
Replies
8
Views
287
Replies
1
Views
182
Replies
0
Views
220
Replies
17
Views
472

1,216,380
Messages
6,130,291
Members
449,570
Latest member
TomMacca52

### 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.

### Which adblocker are you using?

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

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