<?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 Amend Pivot Table VBA to remove multiple Items in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Amend-Pivot-Table-VBA-to-remove-multiple-Items/m-p/118496#M52754</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I created a code stage in my Excel VBO Extended to Select all then exclude certain values from the pivot table filter.&amp;nbsp; However I am not a coder and would like to be able to pass in a variable no of values to exclude in a collection.&lt;/P&gt;&lt;P&gt;Here is my current code that excludes 2 values.&amp;nbsp; But I may have 3 or 4 or 1.&amp;nbsp; Please can someone kindly help me? Thanks.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrancesBarker_1-1737972540141.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/40275i7B7C2B9B8728D33D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="FrancesBarker_1-1737972540141.png" alt="FrancesBarker_1-1737972540141.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2025 10:13:32 GMT</pubDate>
    <dc:creator>FrancesBarker</dc:creator>
    <dc:date>2025-01-27T10:13:32Z</dc:date>
    <item>
      <title>Amend Pivot Table VBA to remove multiple Items</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Amend-Pivot-Table-VBA-to-remove-multiple-Items/m-p/118496#M52754</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I created a code stage in my Excel VBO Extended to Select all then exclude certain values from the pivot table filter.&amp;nbsp; However I am not a coder and would like to be able to pass in a variable no of values to exclude in a collection.&lt;/P&gt;&lt;P&gt;Here is my current code that excludes 2 values.&amp;nbsp; But I may have 3 or 4 or 1.&amp;nbsp; Please can someone kindly help me? Thanks.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FrancesBarker_1-1737972540141.png" style="width: 400px;"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/40275i7B7C2B9B8728D33D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="FrancesBarker_1-1737972540141.png" alt="FrancesBarker_1-1737972540141.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 10:13:32 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Amend-Pivot-Table-VBA-to-remove-multiple-Items/m-p/118496#M52754</guid>
      <dc:creator>FrancesBarker</dc:creator>
      <dc:date>2025-01-27T10:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Amend Pivot Table VBA to remove multiple Items</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Amend-Pivot-Table-VBA-to-remove-multiple-Items/m-p/118870#M52839</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.blueprism.com/t5/user/viewprofilepage/user-id/53714"&gt;@FrancesBarker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where you able to get solution?&lt;/P&gt;&lt;P&gt;I would suggest to check the same on chatgpt or similar&lt;/P&gt;&lt;P&gt;I did gave a try with Chatgpt and got response and looks fine to give try on below solution&lt;/P&gt;&lt;P&gt;Got it! Since you're using Blue Prism, you'll need to ensure that ExcludeCollection is properly passed as a collection in your Blue Prism workflow. Blue Prism collections work like tables with multiple rows, so you'll need to iterate over them inside the Code Stage.&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Updated Code for Blue Prism Code Stage&lt;/STRONG&gt;&lt;/H3&gt;&lt;PRE&gt;Dim ws As Object
Dim pt As Object
Dim pf As Object
Dim excludeItem As String
Dim i As Integer

ws = GetWorksheet(Handle, Workbook, Worksheet)
ws.Activate()

' Reference the PivotTable and PivotField
Set pt = ws.PivotTables(PivotTableName)
Set pf = pt.PivotFields(Field)

' Select All Items First
pf.ClearAllFilters

' Loop through the Blue Prism collection ExcludeCollection
For i = 1 To ExcludeCollection.Rows.Count
    excludeItem = ExcludeCollection.Rows(i).Item("Exclude") ' Adjust column name as needed
    pf.PivotItems(excludeItem).Visible = False
Next i&lt;/PRE&gt;&lt;H3&gt;&lt;STRONG&gt;Key Points&lt;/STRONG&gt;&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Uses a Blue Prism collection (ExcludeCollection)&lt;/STRONG&gt; where each row contains an item to exclude.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Retrieves values dynamically using ExcludeCollection.Rows(i).Item("Exclude")&lt;/STRONG&gt;. Ensure "Exclude" matches the column name in your collection.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Loops through the collection dynamically&lt;/STRONG&gt;, handling any number of values.&lt;/LI&gt;&lt;/OL&gt;&lt;H3&gt;&lt;STRONG&gt;Blue Prism Setup&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;Before the Code Stage, ensure you have a &lt;STRONG&gt;collection&lt;/STRONG&gt; (ExcludeCollection) with a column named "Exclude" containing values to be filtered out.&lt;/LI&gt;&lt;LI&gt;Pass ExcludeCollection as an &lt;STRONG&gt;input parameter&lt;/STRONG&gt; to the Code Stage.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Would you like guidance on setting up the collection in Blue Prism?&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2025 14:27:29 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Amend-Pivot-Table-VBA-to-remove-multiple-Items/m-p/118870#M52839</guid>
      <dc:creator>plnarayana777</dc:creator>
      <dc:date>2025-02-15T14:27:29Z</dc:date>
    </item>
  </channel>
</rss>

