Excel sorting and operation

I’m new to UiPath, can anyone please help me , I need to sort the price and review so that the first column has the most reviews and least price and then only display the first row. I tried different activities but I’m not getting it properly.

Hi @darshanb.is22

Have you tried with Sort Data Table activity

image

Regards,

Hi @darshanb.is22

You can use the excel activity called Sort range which allows you to sort the column based on the conditions. In our case the Reviews column is in descending order and Prices is in the Ascending order. I made like as you want, check the below image for better understanding,
image

Hope it helps!!

Hi @darshanb.is22

Can you share the sample input?

Regards

Hi @darshanb.is22

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:
image

Output:
image

Regards