Sequence:
Main.xaml (14.6 KB)
Macros Code:
Sub FilterData()
Dim ws As Worksheet
Dim lastRow As Long
Dim sortRange As Range
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' Replace "Sheet1" with your actual sheet name
' Find the last row in the data
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Define the range to be sorted (assuming data starts from A1)
Set sortRange = ws.Range("A1:D" & lastRow)
' Sort by maximum reviews (column D) in descending order
sortRange.Sort key1:=ws.Range("D1"), order1:=xlDescending, Header:=xlYes
' Sort by least price (column C) in ascending order
sortRange.Sort key1:=ws.Range("C1"), order1:=xlAscending, Header:=xlYes
End Sub
Input:
Output:
Regards