ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting Question (https://www.excelbanter.com/excel-programming/362853-sorting-question.html)

srroduin

Sorting Question
 
I have a the following code that sorts according to two columns. Column B is
either a variable called SASIncrease or one called SASDecrease. Column N is
a date. I have it putting column B in alphabetical order and secondly
sorting the dates.

Is there a way to put all of the rows with SASIncrease in column B first
followed by all the ones with SASDecrease instead of putting it in
alphabetical order?

Other loops that I have keep messing up if the SASDecrease is before the
SASIncrease rows.

Here's the code:

Range("A10:U" & Range("A65536").End(xlUp).Row).Select 'This will sort using
SAS number (B) and Start date (N)
Selection.Sort Key1:=Range("B10"), key2:=Range("N10"),
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


srroduin

Sorting Question
 
Never mind. I figured it out. :)

"srroduin" wrote:

I have a the following code that sorts according to two columns. Column B is
either a variable called SASIncrease or one called SASDecrease. Column N is
a date. I have it putting column B in alphabetical order and secondly
sorting the dates.

Is there a way to put all of the rows with SASIncrease in column B first
followed by all the ones with SASDecrease instead of putting it in
alphabetical order?

Other loops that I have keep messing up if the SASDecrease is before the
SASIncrease rows.

Here's the code:

Range("A10:U" & Range("A65536").End(xlUp).Row).Select 'This will sort using
SAS number (B) and Start date (N)
Selection.Sort Key1:=Range("B10"), key2:=Range("N10"),
Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



All times are GMT +1. The time now is 08:33 AM.

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