<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Sort Excel column by custom order in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72093#M24698</link>
    <description>Try using the below code :&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="lang-vb s-code-block"&gt;&lt;CODE class="hljs language-vbnet"&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; worksheet,Excel &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;Object&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; rRng &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;Object&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; Header1 &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;integer&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;

Excel = GetWorkbook(handle,&lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;)

worksheet = GetWorkbook(handle,&lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;).ActiveSheet

rRng = worksheet.Range(Data_StartCell,Data_EndCell)

&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; HeaderPresent = &lt;SPAN class="hljs-literal"&gt;true&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;then&lt;/SPAN&gt;

    Header1=&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; HeaderPresent = &lt;SPAN class="hljs-literal"&gt;false&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;then&lt;/SPAN&gt;

    Header1=&lt;SPAN class="hljs-number"&gt;2&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;end&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt;

rRng.Sort(Key1:=worksheet.Range(Order_StartCell,Order_EndCell), Order1:=OrderType,Header:=Header1)

Success = &lt;SPAN class="hljs-literal"&gt;true&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;catch&lt;/SPAN&gt; e &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; Exception

Success = &lt;SPAN class="hljs-literal"&gt;false&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Input Variables Used&lt;/STRONG&gt;- handle , Data_StartCell , Data_EndCell, Order_StartCell, Order_EndCell, OrderType, HeaderPresent&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output Variables -&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Success&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data_StartCell&lt;/STRONG&gt;- "A1"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data_EndCell&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- "E20"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Order_StartCell&lt;/STRONG&gt;- "B1"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Order_EndCell&lt;/STRONG&gt;- "B20"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;OrderType&lt;/STRONG&gt;- 1 (it is of Number type and 1 for Ascending and 2 for Descending)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HeaderPresent&lt;/STRONG&gt;- True or False depending you have headers or not&lt;/P&gt;
&lt;P&gt;Hope the solution works for you.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;Vipul Tiwari&lt;BR /&gt;Senior Process Simplification Developer&lt;BR /&gt;Amazon&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Sun, 03 Oct 2021 11:26:00 GMT</pubDate>
    <dc:creator>EVIPUTI</dc:creator>
    <dc:date>2021-10-03T11:26:00Z</dc:date>
    <item>
      <title>Sort Excel column by custom order</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72090#M24695</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want to sort column from excel file by predefined order. how can we achieve it?&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Rohini Patil&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Sep 2021 14:38:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72090#M24695</guid>
      <dc:creator>RohiniPatil</dc:creator>
      <dc:date>2021-09-29T14:38:00Z</dc:date>
    </item>
    <item>
      <title>RE: Sort Excel column by custom order</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72091#M24696</link>
      <description>Hello Rohini,&lt;BR /&gt;You can run excel Macors ( run Macros action is available) to sort columns.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;Best Regards,&lt;BR /&gt;Ved Sengupta&lt;BR /&gt;RPA Developer&lt;BR /&gt;Deloitte India (Offices of the US)&lt;BR /&gt;Bangalore | INDIA&lt;BR /&gt;*If you find this post helpful mark it as best answer*&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Sep 2021 10:58:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72091#M24696</guid>
      <dc:creator>VedSengupta</dc:creator>
      <dc:date>2021-09-30T10:58:00Z</dc:date>
    </item>
    <item>
      <title>RE: Sort Excel column by custom order</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72092#M24697</link>
      <description>&lt;DIV class="uconBody"&gt;&lt;DIV dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10pt"&gt;&lt;DIV dir="ltr"&gt;for that 1st i have to create macro in the file right? we are downloading this file for application then how can i add macro to it?&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Sep 2021 12:52:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72092#M24697</guid>
      <dc:creator>RohiniPatil</dc:creator>
      <dc:date>2021-09-30T12:52:00Z</dc:date>
    </item>
    <item>
      <title>RE: Sort Excel column by custom order</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72093#M24698</link>
      <description>Try using the below code :&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="lang-vb s-code-block"&gt;&lt;CODE class="hljs language-vbnet"&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; worksheet,Excel &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;Object&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; rRng &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;Object&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; Header1 &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; &lt;SPAN class="hljs-type"&gt;integer&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;

Excel = GetWorkbook(handle,&lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;)

worksheet = GetWorkbook(handle,&lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;).ActiveSheet

rRng = worksheet.Range(Data_StartCell,Data_EndCell)

&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; HeaderPresent = &lt;SPAN class="hljs-literal"&gt;true&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;then&lt;/SPAN&gt;

    Header1=&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;else&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; HeaderPresent = &lt;SPAN class="hljs-literal"&gt;false&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;then&lt;/SPAN&gt;

    Header1=&lt;SPAN class="hljs-number"&gt;2&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;end&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt;

rRng.Sort(Key1:=worksheet.Range(Order_StartCell,Order_EndCell), Order1:=OrderType,Header:=Header1)

Success = &lt;SPAN class="hljs-literal"&gt;true&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;catch&lt;/SPAN&gt; e &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; Exception

Success = &lt;SPAN class="hljs-literal"&gt;false&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Input Variables Used&lt;/STRONG&gt;- handle , Data_StartCell , Data_EndCell, Order_StartCell, Order_EndCell, OrderType, HeaderPresent&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output Variables -&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Success&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data_StartCell&lt;/STRONG&gt;- "A1"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data_EndCell&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;- "E20"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Order_StartCell&lt;/STRONG&gt;- "B1"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Order_EndCell&lt;/STRONG&gt;- "B20"&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;OrderType&lt;/STRONG&gt;- 1 (it is of Number type and 1 for Ascending and 2 for Descending)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HeaderPresent&lt;/STRONG&gt;- True or False depending you have headers or not&lt;/P&gt;
&lt;P&gt;Hope the solution works for you.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;Vipul Tiwari&lt;BR /&gt;Senior Process Simplification Developer&lt;BR /&gt;Amazon&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Sun, 03 Oct 2021 11:26:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72093#M24698</guid>
      <dc:creator>EVIPUTI</dc:creator>
      <dc:date>2021-10-03T11:26:00Z</dc:date>
    </item>
    <item>
      <title>RE: Sort Excel column by custom order</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72094#M24699</link>
      <description>Also do check &lt;A href="https://community.blueprism.com/communities/community-home/digestviewer/viewthread?GroupId=85&amp;amp;MID=94&amp;amp;CommunityKey=d8a0860f-1370-4a8d-a272-ad61dbc9b3f3&amp;amp;tab=digestviewer&amp;amp;ReturnUrl=%2Fcommunities%2Fcommunity-home%2Fdigestviewer%3FMessageKey%3Df60a971b-4be6-4367-8a8c-2e448ed9331b%26CommunityKey%3Dd8a0860f-1370-4a8d-a272-ad61dbc9b3f3" target="_blank" rel="noopener"&gt;this&lt;/A&gt; thread also .&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;Vipul Tiwari&lt;BR /&gt;Senior Process Simplification Developer&lt;BR /&gt;Amazon&lt;BR /&gt;------------------------------&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Sun, 03 Oct 2021 11:26:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Sort-Excel-column-by-custom-order/m-p/72094#M24699</guid>
      <dc:creator>EVIPUTI</dc:creator>
      <dc:date>2021-10-03T11:26:00Z</dc:date>
    </item>
  </channel>
</rss>

