Sort Excel column by custom order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-09-21 03:38 PM
Hi,
I want to sort column from excel file by predefined order. how can we achieve it?
------------------------------
Rohini Patil
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-09-21 11:58 AM
You can run excel Macors ( run Macros action is available) to sort columns.
------------------------------
------------------------------
Best Regards,
Ved Sengupta
RPA Developer
Deloitte India (Offices of the US)
Bangalore | INDIA
*If you find this post helpful mark it as best answer*
------------------------------
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-09-21 01:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-10-21 12:26 PM
Dim worksheet,Excel As Object
Dim rRng as Object
Dim Header1 as integer
try
Excel = GetWorkbook(handle,Nothing)
worksheet = GetWorkbook(handle,Nothing).ActiveSheet
rRng = worksheet.Range(Data_StartCell,Data_EndCell)
if HeaderPresent = true then
Header1=1
else if HeaderPresent = false then
Header1=2
end if
rRng.Sort(Key1:=worksheet.Range(Order_StartCell,Order_EndCell), Order1:=OrderType,Header:=Header1)
Success = true
catch e as Exception
Success = false
End try
Input Variables Used- handle , Data_StartCell , Data_EndCell, Order_StartCell, Order_EndCell, OrderType, HeaderPresent
Output Variables - Success
Suppose you want have data from A1:E20 column and you need to sort column B only. So below are the inputs which you can use:
Data_StartCell- "A1"
Data_EndCell - "E20"
Order_StartCell- "B1"
Order_EndCell- "B20"
OrderType- 1 (it is of Number type and 1 for Ascending and 2 for Descending)
HeaderPresent- True or False depending you have headers or not
Hope the solution works for you.
------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification Developer
Amazon
------------------------------
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-10-21 12:26 PM
------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification Developer
Amazon
------------------------------
------------------------------
