Hello,
I am looking to have two sorting done with my code. First order is from Custom List and the 2nd order is Smallest to Largest.
Here is my code:
The result of the Code does not sort the way i wanted to be.
I want the result of the sorting to be as following:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Variance $[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD](8000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](5000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](4000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](1200)[/TD]
[TD]Shortage[/TD]
[/TR]
[TR]
[TD]1000[/TD]
[TD]Overage[/TD]
[/TR]
[TR]
[TD]1200[/TD]
[TD]Overage[/TD]
[/TR]
</tbody>[/TABLE]
Any help from your expertise is much appreciated...thank you
I am looking to have two sorting done with my code. First order is from Custom List and the 2nd order is Smallest to Largest.
Here is my code:
Code:
Dim sStatus As Range
Dim sVarValue As Range
Application.AddCustomList ListArray:=Array("0 Count","Shortage","Overage")
Set sStatus = Rows(1).Find("Status")
Set sVarValue=Rows(1).Find("Variance $")
ActiveSheet.Sort.SortFields.Clear
Range("A1").CurrentRegion.Resize(Range("A1").CurrentRegion.Rows.Count - 1).Sort Key1:=sStatus, Order1:=xlAscending, Ordercustom:=Application.CustomListCount, _
Key2:=sVarValue, Order2:=xlAscending, Header:=xlYes, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
The result of the Code does not sort the way i wanted to be.
I want the result of the sorting to be as following:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Variance $[/TD]
[TD]Status[/TD]
[/TR]
[TR]
[TD](8000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](5000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](4000)[/TD]
[TD]0 Count[/TD]
[/TR]
[TR]
[TD](1200)[/TD]
[TD]Shortage[/TD]
[/TR]
[TR]
[TD]1000[/TD]
[TD]Overage[/TD]
[/TR]
[TR]
[TD]1200[/TD]
[TD]Overage[/TD]
[/TR]
</tbody>[/TABLE]
Any help from your expertise is much appreciated...thank you
Last edited: