<?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: AutoFilter Dynamic Range in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56711#M10848</link>
    <description>Not entirely sure why it is giving you an error, but you could try doing it without specifying the range. If you select a cell on the header row, AutoFilter should grab everything automatically:&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;sheet.Range("A2").Select
excel.Selection.AutoFilter Field:=4, Criteria1:="611"​&lt;/CODE&gt;&lt;/PRE&gt;
------------------------------&lt;BR /&gt;Nicholas Zejdlik&lt;BR /&gt;RPA Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Thu, 19 Nov 2020 17:09:00 GMT</pubDate>
    <dc:creator>NicholasZejdlik</dc:creator>
    <dc:date>2020-11-19T17:09:00Z</dc:date>
    <item>
      <title>AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56708#M10845</link>
      <description>Hello,&amp;nbsp;&lt;BR /&gt;Im trying to autofilter a Excel Dynamic Range.&lt;BR /&gt;If I run the code in a normal table, it works, but when I run the same code to filter a dynamic range I get an error (autofilter failed).&lt;BR /&gt;&lt;BR /&gt;I need to filter the column "D" with two criterias&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="30309.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/30440i584694B0AF611036/image-size/large?v=v2&amp;amp;px=999" role="button" title="30309.png" alt="30309.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;BR /&gt;&lt;BR /&gt;This is the code I'm using:&lt;BR /&gt;&lt;BR /&gt;Dim sw, dw As Object&lt;BR /&gt;Dim ss, ds As Object&lt;BR /&gt;Dim excel, sheet, varUsedRange As Object&lt;BR /&gt;Dim FilteredCount as Long&lt;BR /&gt;&lt;BR /&gt;Try&lt;BR /&gt;&lt;BR /&gt;sw = GetWorkbook(handle, workbookname)&lt;BR /&gt;ss = GetWorksheet(handle, workbookname, worksheetname)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sw.Activate()&lt;BR /&gt;ss.Activate()&lt;BR /&gt;excel = ss.Application&lt;BR /&gt;sheet = excel.ActiveSheet&lt;BR /&gt;&lt;BR /&gt;varUsedRange = sheet.UsedRange().address&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If sheet.AutoFilterMode Then&lt;BR /&gt;sheet.AutoFilterMode = False&amp;nbsp;&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;sheet.range(varUsedRange ).AutoFilter (Field:=4, Criteria1:="=611")&lt;BR /&gt;&lt;BR /&gt;FilteredCount = sheet.AutoFilter.Range.Columns("D").SpecialCells(12).Cells.Count - 1&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If FilteredCount &amp;gt; 0 then&lt;BR /&gt;&lt;BR /&gt;End if&lt;BR /&gt;&lt;BR /&gt;Success = True&lt;BR /&gt;&lt;BR /&gt;Catch e As Exception&lt;BR /&gt;Success = False&lt;BR /&gt;Message = e.Message&lt;BR /&gt;Finally&lt;BR /&gt;sw = Nothing&lt;BR /&gt;ss = Nothing&lt;BR /&gt;dw = Nothing&lt;BR /&gt;ds = Nothing&lt;BR /&gt;excel = Nothing&lt;BR /&gt;sheet = Nothing&lt;BR /&gt;varUsedRange = Nothing&lt;BR /&gt;End Try&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Israel Nunes Sousa&lt;BR /&gt;RPA Developer&lt;BR /&gt;Indra&lt;BR /&gt;America/Sao_Paulo&lt;BR /&gt;------------------------------</description>
      <pubDate>Thu, 19 Nov 2020 02:04:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56708#M10845</guid>
      <dc:creator>IsraelNunes_Sou</dc:creator>
      <dc:date>2020-11-19T02:04:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56709#M10846</link>
      <description>What's the difference between the normal table and the dynamic range?&lt;BR /&gt;&lt;BR /&gt;If you're looking to filter by two criteria, try changing the autofilter line to this: &lt;SPAN&gt;&lt;CODE&gt;sheet.range(varUsedRange ).AutoFilter (Field:=4, Criteria1:="611", Operator:=2, Criteria2:="SecondFilterValue")&lt;/CODE&gt; (2 = xlOr)&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Nicholas Zejdlik&lt;BR /&gt;RPA Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2020 15:33:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56709#M10846</guid>
      <dc:creator>NicholasZejdlik</dc:creator>
      <dc:date>2020-11-19T15:33:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56710#M10847</link>
      <description>Thanks &lt;A class="user-content-mention" data-sign="@" data-contactkey="e42d12b2-a3f6-4f36-a821-9db8ee48b837" data-tag-text="@Nicholas Zejdlik" href="https://community.blueprism.com/network/profile?UserKey=e42d12b2-a3f6-4f36-a821-9db8ee48b837" data-itemmentionkey="e6dbdd05-8854-4011-94d0-562d15ef3e76"&gt;@Nicholas Zejdlik&lt;/A&gt;&lt;BR /&gt;That is something I will need too.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;About your question:&lt;BR /&gt;&lt;BR /&gt;The normal table its only a sheet with the column name, and the lines,&lt;BR /&gt;&lt;BR /&gt;This is my normal table:&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="30294.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/30425i6B400FDDBFB9730C/image-size/large?v=v2&amp;amp;px=999" role="button" title="30294.png" alt="30294.png" /&gt;&lt;/span&gt;&lt;BR /&gt;And I use those register to generate the dynamic range.&lt;BR /&gt;&lt;BR /&gt;I think its not working for dynamic range, because I can't put a filter in the first line&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="30295.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/30419i91BA25EAB23F4D95/image-size/large?v=v2&amp;amp;px=999" role="button" title="30295.png" alt="30295.png" /&gt;&lt;/span&gt;&lt;BR /&gt;The button get inactive&lt;BR /&gt;&lt;BR /&gt;And I can't delete the first line, because its an automatic table, generate by Excel.&lt;BR /&gt;&lt;BR /&gt;I have tried, with a range, from "D2:Until the end" but also didn't work.&lt;BR /&gt;&lt;BR /&gt;I don't know if my case is clear, if not, I can try explain in other way.&lt;BR /&gt;&lt;BR /&gt;I need this so bad. Im trying to do it about 2 weeks, with no success.&amp;nbsp;&lt;/DIV&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;​&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Israel Nunes Sousa&lt;BR /&gt;RPA Developer&lt;BR /&gt;Indra&lt;BR /&gt;America/Sao_Paulo&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:20:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56710#M10847</guid>
      <dc:creator>IsraelNunes_Sou</dc:creator>
      <dc:date>2020-11-19T16:20:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56711#M10848</link>
      <description>Not entirely sure why it is giving you an error, but you could try doing it without specifying the range. If you select a cell on the header row, AutoFilter should grab everything automatically:&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;sheet.Range("A2").Select
excel.Selection.AutoFilter Field:=4, Criteria1:="611"​&lt;/CODE&gt;&lt;/PRE&gt;
------------------------------&lt;BR /&gt;Nicholas Zejdlik&lt;BR /&gt;RPA Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2020 17:09:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56711#M10848</guid>
      <dc:creator>NicholasZejdlik</dc:creator>
      <dc:date>2020-11-19T17:09:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56712#M10849</link>
      <description>Didn't work&amp;nbsp;&lt;BR /&gt;Give me the same error "AutoFilter Method of Range Class Failed"&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Israel Nunes Sousa&lt;BR /&gt;RPA Developer&lt;BR /&gt;Indra&lt;BR /&gt;America/Sao_Paulo&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2020 20:25:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56712#M10849</guid>
      <dc:creator>IsraelNunes_Sou</dc:creator>
      <dc:date>2020-11-19T20:25:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56713#M10850</link>
      <description>On second glance on those tables, the one you're working on looks to be a Pivot Table, which doesn't use AutoFilter. I get the same error that you are getting if I try to use AutoFilter macros on a pivot table.&lt;BR /&gt;&lt;BR /&gt;I'd suggest using the Record Macro feature in Excel to get a look at the specific code you'd need to run to filter the pivot table to your needs. Any VBA macros can be pretty easily imported into Blue Prism code. I believe the code you're looking for is going to be something like this:&lt;BR /&gt;
&lt;PRE class="language-csharp"&gt;&lt;CODE&gt;sheet.PivotTables(1).PivotFields(4).PivotFilters.Add2 Type:=xlCaptionEquals, Value1:="611"​&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Nicholas Zejdlik&lt;BR /&gt;RPA Developer&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Nov 2020 00:31:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56713#M10850</guid>
      <dc:creator>NicholasZejdlik</dc:creator>
      <dc:date>2020-11-20T00:31:00Z</dc:date>
    </item>
    <item>
      <title>RE: AutoFilter Dynamic Range</title>
      <link>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56714#M10851</link>
      <description>OMG! I can't believe, it works!&lt;BR /&gt;&lt;BR /&gt;I only had to make some adjustment to get the field I wanted, and use two criteria.&lt;BR /&gt;&lt;BR /&gt;This is the final code:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Dim ss, ds As Object&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Dim excel, sheet As Object&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Dim i As Decimal&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Try&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;ss = GetWorksheet(handle, workbookname, worksheetname)&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;ss.Activate()&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;excel = ss.Application&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;sheet = excel.ActiveSheet&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;'sheet.PivotTables(1).PivotFields("Conta do R").PivotFilters.Add (Type:=15, Value1:= "631*"​, Value2:= "611*")&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;With sheet.PivotTables(1).PivotFields("Conta do R")&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;For i=1 to .PivotItems.Count&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;If left(.PivotItems(i).Name, 3) = "631" Or left(.PivotItems(i).Name, 3) = "611" Then&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;.PivotItems(i).Visible = True&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Else&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;.PivotItems(i).Visible = False&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;End If&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Next i&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;End With&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Success = True&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Catch e As Exception&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Success = False&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Message = e.Message&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;Finally&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;ss = Nothing&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;ds = Nothing&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;excel = Nothing&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;sheet = Nothing&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #ffcc99;"&gt;&lt;CODE&gt;End Try&lt;/CODE&gt;&lt;/SPAN&gt;&lt;BR /&gt;
&lt;DIV class="media" style="overflow: hidden;"&gt;I tried to insert an ".AutoSort 1" but didnt work.&lt;/DIV&gt;
&lt;BR /&gt;&lt;BR /&gt;Im so sorry, its Pivot Table, and I saying wrong all the time,&lt;BR /&gt;Luck you discovered !&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Israel Nunes Sousa&lt;BR /&gt;RPA Developer&lt;BR /&gt;Indra&lt;BR /&gt;America/Sao_Paulo&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Nov 2020 01:50:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/AutoFilter-Dynamic-Range/m-p/56714#M10851</guid>
      <dc:creator>IsraelNunes_Sou</dc:creator>
      <dc:date>2020-11-20T01:50:00Z</dc:date>
    </item>
  </channel>
</rss>

