Need to sort a row of data and automatically copy in to another ro

G

Guest

I have a row of 6 random ordered numbers. I with to find out how to
automatically copy them into another row and have them in Ascending numerical
order. I'm at a loss to figure out what function can do this.

Example:
Input 9 4 56 8 2 27

Output 2 4 8 9 27 56

Thanks, Scidoc
 
B

Bernard Liengme

One could make a UDF (user defined function) Are you ready to explore VBA?
best wishes
 
B

Bernard Liengme

Try

Option Base 1

Function sortme(myrange)
Application.Volatile
n = myrange.Count
ReDim myarray(n)
For j = 1 To n
myarray(j) = myrange(j)
Next
For k = 1 To n - 1
For j = k To n
If myarray(j) < myarray(k) Then
holdme = myarray(j)
myarray(j) = myarray(k)
myarray(k) = holdme
End If
Next j
Next k
sortme = myarray
End Function

Need help with VBA? See David McRitchie's site on "getting started" with
VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
G

Guest

Another play to try out ..

Assuming the inputs are in B1 across

In B2:
=IF(B1="","",B1+COLUMNS($A:A)/10^10)
Leave A2 blank

In B3:
=IF(COLUMNS($A:A)>COUNT(2:2),"",INDEX(1:1,MATCH(SMALL(2:2,COLUMNS($A:A)),2:2,0)))
Select B2:B3, copy across to cover the max expected extent of inputs (in B1
across). B3 across will return the required ascending sort of inputs, all
neatly bunched to the left. Duplicate input numbers, if any, are also catered
for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top