Organising table in ascending/descending order

Newbie`

New Member
Joined
Jun 8, 2018
Messages
1
I want to make a table showing Item, Price, Quantity Sold and Total.

I can set either column to ascending/descending without any issue and have that include the other columns. But i want to know if there is a way for it to show for example the highest total with the highest quantity?


Is it possible, any help would be appreciated.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
.
This macro presumes your data begins on the third row and your Column Headers are on the second row:

Sub SrtDescendCnD()


wsLast_Row = Cells(Rows.Count, 1).End(xlUp).Row
With ActiveWorkbook.ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("C3:C" & wsLast_Row), Order:=xlDescending
.SortFields.Add Key:=Range("D3:D" & wsLast_Row), Order:=xlDescending
.SetRange Range("A3:D" & wsLast_Row)
.Header = xlNo
.Apply
End With
End Sub
Code:
 
Last edited:
Upvote 0
.
Actually, disregard the previous post. Try this one :

Code:
Sub SortIndividualJR()
    Dim Rng1 As Range
    Dim Rng2 As Range
    Dim ws As Worksheet
    Set ws = ActiveSheet
    On Error Resume Next
    Set Rng1 = Application.InputBox(Prompt:="Range Selection:", _
                                    Title:="Kutools for excel", Type:=8)
    Application.ScreenUpdating = False
    For Each Rng2 In Rng1
        With ws.Sort
            .SortFields.Clear
            .SortFields.Add Key:=Rng2, Order:=xlDescending
            .SetRange ws.Range(Rng2, Rng2.End(xlDown))
            .Header = xlNo
            .MatchCase = False
            .Apply
        End With
    Next Rng2
    Application.ScreenUpdating = True
End Sub


(I returned too late to the previous post to either delete it or edit so the code was formatted correctly. If a Moderator wants to delete post #2 , that would be great.)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,225,754
Messages
6,186,825
Members
453,377
Latest member
JoyousOne

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top