Sort rows in the Excel by column name

Hi There,

I have my output excel with the data starts from A11. I want to sort the data based on the “Column P” values in ascending. Please help to achieve.

Note: “Sort range” is not working as the data actually starts from row 11.

TIA

HI @ramya_anbazhagan ,

Step 1: Read the Excel file AS DT. (Select the data starting from row 11)

Step 2: DT = DT.AsEnumerable().OrderBy(Function(row) row.Field(Of Object)("Your Column Name Here")).CopyToDataTable()

Step 3: Write the sorted data back to an Excel file

Thanks!

Hi @ramya_anbazhagan

Try this

1.Read Range activity set Range as 11
2.Use the below Linq query

(From row In dt.AsEnumerable()
Order By Convert.ToInt32(row("P"))
Select row).CopyToDataTable()

3.Write Range activity

Regards,

dtSorted = dtData.AsEnumerable().OrderBy(Function(row) row("Column Name")).CopyToDataTable()

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.