+ Reply to Thread
Results 1 to 8 of 8

Use a variable to change pivot table filter

  1. #1
    Registered User
    Join Date
    11-03-2018
    Location
    mpls
    MS-Off Ver
    360
    Posts
    29

    Use a variable to change pivot table filter

    I am trying to use a variable (Apple) to change pivot table filter to an account number on Client sheet. The first code generated by record button to change filter to account number 999421 works. The second is not changing the filter to the account number associates with variable "Apple". Any help would be appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Use a variable to change pivot table filter

    You will probably have to loop through the values in the range Apple.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Use a variable to change pivot table filter

    It would need to be:

    Please Login or Register  to view this content.
    Rory

  4. #4
    Registered User
    Join Date
    11-03-2018
    Location
    mpls
    MS-Off Ver
    360
    Posts
    29

    Re: Use a variable to change pivot table filter

    I am now receiving the following error: This item could not be found in the OLAP cube.

    I updated the code and I pasted the value of Apple in cell 4,1 and notice that the value from "Sheets.Client" is formatted as a number and the value from the Pivot Table is formated as text, the original source is number format. Seems like the Pivot filter is converting data to text format. Not sure if this is issue.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-03-2018
    Location
    mpls
    MS-Off Ver
    360
    Posts
    29

    Re: Use a variable to change pivot table filter

    Here is file.
    Attached Files Attached Files

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Use a variable to change pivot table filter

    I missed an ampersand:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-03-2018
    Location
    mpls
    MS-Off Ver
    360
    Posts
    29

    Re: Use a variable to change pivot table filter

    Thank you for your help. I have spent a week trying to figure out how to filter a pivot table using a variable. I attached the working spreadsheet so hopefully this could help others.
    Attached Files Attached Files

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Use a variable to change pivot table filter

    Glad to help. Thanks for the rep and kind words!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot table filter with variable
    By oulouis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2018, 11:15 AM
  2. Problem trying to use variable to filter pivot table.
    By dquigley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2016, 12:07 PM
  3. Pivot Table to Filter using a variable
    By shanegr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-18-2015, 07:34 AM
  4. Replies: 6
    Last Post: 07-31-2014, 12:56 PM
  5. Automatically filter Pivot Table using a variable
    By ctpoodle in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-10-2013, 02:53 PM
  6. Pivot table, assigning a cell wo be change the Pivot table filter
    By jwongsf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2012, 05:00 PM
  7. Change Pivot table Filter Based on Cell Value *Multiple Filter items* Possible?
    By Flydd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2012, 06:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1