<?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 VBA Excel Sorting in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/VBA-Excel-Sorting/m-p/85463#M36454</link>
    <description>Hi Guys,


I created a below code, and could not find what is wrong there - check code does not show anything.

Exception details after calculation stage attached.

Code:

dim wb as excel.workbook
dim ws as excel.worksheet
'Dim wb as Object = GetWorkbook(handle,workbookname)
'Dim ws as Excel.Worksheet

Dim Xlapp as Object=getobject(,"Excel.Application")

for each wb in Xlapp.workbooks

if wb.name = [workbookname] then
wb.activate
exit for
end if
next
ws = wb.worksheets(worksheetname)
ws.activate

ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1).Sort.SortFields.Clear
ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1).Sort.SortFields.Add (Key:= ws.range("E3:E"&amp;amp;[Number_of_Rows]), SortOn:=1, Order:=2, DataOption:=1)
With ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1) .Sort
.SetRange (ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1))
.Header = 0
.MatchCase = False
.Orientation = 1
.SortMethod = 1
.Apply
End With

handle, Number_of_Rows, workbookname, and worksheetname are Inputs for the code above.


Many Thanks,

Jarek</description>
    <pubDate>Tue, 02 Jan 2018 16:01:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-02T16:01:00Z</dc:date>
    <item>
      <title>VBA Excel Sorting</title>
      <link>https://community.blueprism.com/t5/Product-Forum/VBA-Excel-Sorting/m-p/85463#M36454</link>
      <description>Hi Guys,


I created a below code, and could not find what is wrong there - check code does not show anything.

Exception details after calculation stage attached.

Code:

dim wb as excel.workbook
dim ws as excel.worksheet
'Dim wb as Object = GetWorkbook(handle,workbookname)
'Dim ws as Excel.Worksheet

Dim Xlapp as Object=getobject(,"Excel.Application")

for each wb in Xlapp.workbooks

if wb.name = [workbookname] then
wb.activate
exit for
end if
next
ws = wb.worksheets(worksheetname)
ws.activate

ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1).Sort.SortFields.Clear
ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1).Sort.SortFields.Add (Key:= ws.range("E3:E"&amp;amp;[Number_of_Rows]), SortOn:=1, Order:=2, DataOption:=1)
With ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1) .Sort
.SetRange (ws.Range("A3:K"&amp;amp;[Number_of_Rows]-1))
.Header = 0
.MatchCase = False
.Orientation = 1
.SortMethod = 1
.Apply
End With

handle, Number_of_Rows, workbookname, and worksheetname are Inputs for the code above.


Many Thanks,

Jarek</description>
      <pubDate>Tue, 02 Jan 2018 16:01:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/VBA-Excel-Sorting/m-p/85463#M36454</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-02T16:01:00Z</dc:date>
    </item>
  </channel>
</rss>

