+ Reply to Thread
Results 1 to 7 of 7

Select Pivot Slicer Item when A1 Value Changes

  1. #1
    Registered User
    Join Date
    05-02-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    84

    Question Select Pivot Slicer Item when A1 Value Changes

    I'm trying to select an item in Pivot Slicer when I change "A1" value.
    So when I change the "A1" value to "ABC" the code should look for "ABC" in the Slicer Item and select it.
    "A1" value will be same as the items in the slicer.

    Here is my try, but doesn't seems to work and doesn't look right

    Please Login or Register  to view this content.
    Thank you for help!

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Select Pivot Slicer Item when A1 Value Changes

    This worked for me in a very simple test.

    Please Login or Register  to view this content.
    If you still need help post example workbook which illustrates the problem
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-02-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    84

    Re: Select Pivot Slicer Item when A1 Value Changes

    This works, I was missing the .ClearAllFilters
    Thank you!

    If I want to do the same for Pivot table filter instead would my code look something like this?

    Please Login or Register  to view this content.
    Looks like I'm missing .Visible property and others
    I added the ManualUpdate because I don't want to refresh on each status change. But not sure if I did it correctly
    Last edited by ggmkp; 10-18-2019 at 11:37 AM.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Select Pivot Slicer Item when A1 Value Changes

    Code works for me.

    If it is not doing what you expect then post example workbook to illustrate the problem

  5. #5
    Registered User
    Join Date
    05-02-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    84

    Re: Select Pivot Slicer Item when A1 Value Changes

    I'm getting an error at "Field.CurrentPage = A1Value".

    Reads "Run-time error 1004. Unable to set CurrentPage property of PivotField class".

    This is probably because I'm reading from CurrentPage but have pivot table is in a different sheet ("Sheet2")

    And I have this code in Sheet 1
    Last edited by ggmkp; 10-21-2019 at 03:25 PM.

  6. #6
    Registered User
    Join Date
    05-02-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    84

    Re: Select Pivot Slicer Item when A1 Value Changes

    I tried to change it to filter the Row Label instead:

    Please Login or Register  to view this content.
    But now I get a compile error "Named argument not found" at .PivotFilters.Add
    I tried adding quotation on "A1Value" but with or without I'm getting same error.


    I have the code in Sheet 1, and the Pivot table is in Sheet 2.

  7. #7
    Registered User
    Join Date
    05-02-2019
    Location
    USA
    MS-Off Ver
    2016
    Posts
    84

    Re: Select Pivot Slicer Item when A1 Value Changes

    I figured it out.

    It's not Type:=xlValueEquals

    It's Type:=xlCaptionEquals

+ 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. Replies: 0
    Last Post: 08-24-2017, 12:53 AM
  2. how to select slicer item from a range cell
    By maximeb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2017, 10:06 PM
  3. [SOLVED] Run macro to change pivot table row field when user selected a slicer item
    By Chrispelletier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2016, 09:44 AM
  4. Pivot Chart changes total when I select items from the slicer
    By Mrs.H in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-11-2016, 01:55 PM
  5. Workbook_Open to select first item in slicer/pivot
    By kev_33 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2015, 01:08 AM
  6. [SOLVED] Pivot Item. How to select only one.
    By mortphil in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-15-2014, 10:46 AM
  7. How to auto select from a Slicer last or top item
    By xtrenge in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-07-2014, 06:22 PM

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