Hi All.
I would like to sort my set of data (contains both negative and positive numbers) based in ascending order (if the values are negative) and in descending order (if the values are positive).
How can I do that?
Below, I was able to sort the data on column E in ascending order.
I need help in sorting in descending order if the values are positive.
Sub Step5()
Dim strDataRange As Range
Dim keyRange As Range
Dim lrow As Long
lrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set strDataRange = Range("B2:L" & lrow)
Set keyRange = Range("E1")
strDataRange.Sort Key1:=keyRange, Order1:=xlAscending
End Sub
I would like to sort my set of data (contains both negative and positive numbers) based in ascending order (if the values are negative) and in descending order (if the values are positive).
How can I do that?
Below, I was able to sort the data on column E in ascending order.
I need help in sorting in descending order if the values are positive.
Sub Step5()
Dim strDataRange As Range
Dim keyRange As Range
Dim lrow As Long
lrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set strDataRange = Range("B2:L" & lrow)
Set keyRange = Range("E1")
strDataRange.Sort Key1:=keyRange, Order1:=xlAscending
End Sub