Is there a better Sort than Excel's default Sort?

N

Nick

Hi Gurus,
Is there a way to make sorting a selection easier? For example, is
there a way to simply select a list of data in a column, right-click
or press a button/code, and have the selection sorted ascending? I
tried recording a macro, but the sort always goes back to the starting
cell reference.

Our workbook is just set up with different lists of people's names in
different columns. We want to make a selection in a column, or select
multiple lists across columns, and then want the names to sort
alphabetically in the different columns from top to bottom, no header.

In Excel xp's sort, you have to go through a warning and a couple of
windows, asking if you want to expand the selection and if you have a
header, etc. This wastes time...

Thanks!
 
J

john

Nick,
paste the macro you recorded - this will help others better understand what
you are trying to do.
 
J

Jim Cone

Try this slightly modified recorded macro.
Try it on some test data first.
It sorts only the first column of the selected data...
'--
Sub Macro1()
Selection.Columns(1).Sort Key1:=Selection(1), _
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
--
Jim Cone
Portland, Oregon USA




"Nick" <[email protected]>
wrote in message
Hi Gurus,
Is there a way to make sorting a selection easier? For example, is
there a way to simply select a list of data in a column, right-click
or press a button/code, and have the selection sorted ascending? I
tried recording a macro, but the sort always goes back to the starting
cell reference.

Our workbook is just set up with different lists of people's names in
different columns. We want to make a selection in a column, or select
multiple lists across columns, and then want the names to sort
alphabetically in the different columns from top to bottom, no header.

In Excel xp's sort, you have to go through a warning and a couple of
windows, asking if you want to expand the selection and if you have a
header, etc. This wastes time...

Thanks!
 
N

Nick

Thanks guys,
Here's the macro for just one range. The ranges can vary in the
different columns.


Sub mcrSortStudentNames()

Range("B15").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("B15"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal

End Sub
 
P

Peter T

In Excel 2003 or earlier
rt-click on a toolbar and Customize toolbars
In the Commands tab, Categories, select "Data"
In Commands you should see three Sort buttons
Sort...
Sort Ascending
Sort Descending

Sounds like you want the second button, drag it on to a toolbar. Note its
icon is identical to that of the one you don't like.

Regards,
Peter T
 
J

jason

In Excel 2003 or earlier
rt-click on a toolbar and Customize toolbars
In the Commands tab, Categories, select "Data"
In Commands you should see three Sort buttons
Sort...
Sort Ascending
Sort Descending

Sounds like you want the second button, drag it on to a toolbar. Note its
icon is identical to that of the one you don't like.

Regards,
Peter T









- Show quoted text -

sample bubble sort i made:

For i = 1 To YYY - 1
For j = i + 1 To YYY

If Worksheets("A").Cells(74 + i, 3) > Worksheets
("A").Cells(74 + j, 3) Then

Temp1 = Worksheets("A").Cells(74 + j, 3)
Worksheets("A").Cells(74 + j, 3) = Worksheets
("A").Cells(74 + i, 3)
Worksheets("A").Cells(74 + i, 3) = Temp1

Temp2 = Worksheets("A").Cells(74 + j, 1)
Worksheets("A").Cells(74 + j, 1) = Worksheets
("A").Cells(74 + i, 1)
Worksheets("A").Cells(74 + i, 1) = Temp2

Temp3 = Worksheets("A").Cells(74 + j, 2)
Worksheets("A").Cells(74 + j, 2) = Worksheets
("A").Cells(74 + i, 2)
Worksheets("A").Cells(74 + i, 2) = Temp3


End If
Next j
Next i
 

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

Top