ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort row values descending (https://www.excelbanter.com/excel-programming/291892-sort-row-values-descending.html)

Wendy[_6_]

Sort row values descending
 
I need to sort values in a row in descending order.

Example:
1,5,6,7
2,6,3,5
3,2,8,1

Should sort:
7,6,5,1
6,5,3,2
8,3,2,1

I can't figure out the code to do this. Any help?
Here's what I have so far:

For Each rw In Worksheets("qrysctrucks").Rows
rw.Select
Selection.Sort Key1:=Rows(1), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
Next rw


Mark Rosenkrantz[_2_]

Sort row values descending
 
Wendy;

You don't need a macro, but you can use the recorder to see what it spits
out when you do this :

Select a row, or the rows
Choose Sort.
In the dialogbox, choose options.
Choose : sort left to right.
Choose your order and there you go.

Mark.

More Excel ? www.rosenkrantz.nl or
--------------------------------------------------------------------


"Wendy" wrote in message
...
I need to sort values in a row in descending order.

Example:
1,5,6,7
2,6,3,5
3,2,8,1

Should sort:
7,6,5,1
6,5,3,2
8,3,2,1

I can't figure out the code to do this. Any help?
Here's what I have so far:

For Each rw In Worksheets("qrysctrucks").Rows
rw.Select
Selection.Sort Key1:=Rows(1), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
Next rw





All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com