+ Reply to Thread
Results 1 to 2 of 2

Referencing Slicer in VBA

  1. #1
    Registered User
    Join Date
    10-14-2023
    Location
    U.S.
    MS-Off Ver
    2309 Build 16.0.16827.20130
    Posts
    4

    Question Referencing Slicer in VBA

    I am trying to get a VBA code to undo the last slicer selection made (after certain criteria are met), but I can't seem to get VBA to recognize the slicer by name.

    Whenever I try to reference it I get out or range or does not support method errors, and after adding line-by-line error detection it seems the part it consistently gets stuck on is that it can't find the slicer on the sheet, and i've triple-checked the names and all that to verify it wasn't a typo issue.

    Does anyone have any experience referencing slicers in VBA that can give me a basic 'how to reference it' format that worked for them? I tried slicercache but... I just don't know what exactly I need to be pointing this at.

    Specifically i'm trying to store the 'last selection' made in the slicercache and if that action would cause the pivot table to overrun a certain cell (selecting more than 6 options at the same time) the code will display a message saying not to do that and then un-do the selection they just made without clearing the entire slicer. I think i've got the rest figured out, I just can't figure out how to get the code to find it.

  2. #2
    Forum Expert ByteMarks's Avatar
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,176

    Re: Referencing Slicer in VBA

    You should be able to reference it by name. If it's a slice of a pivot table then the name will be the same as the field it's connected to.

    For example, you could have a function to find the slicer
    Please Login or Register  to view this content.
    Then use that in a procedure
    Please Login or Register  to view this content.

+ 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. Disconnect Slicer, Change Pivot Source, Reonnect Slicer
    By ensi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2020, 04:26 AM
  2. Show value of highest slicer selections (multi selected items in slicer
    By saudi_red_neck in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-01-2020, 05:37 AM
  3. VBA Disconnecting Slicer, Updating PivotTable Source, Reconnecting Slicer
    By CowboyFlipflop in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-22-2019, 04:00 PM
  4. Loop through slicer, while also selecting single slicer value on separate slicer
    By as_sass in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2018, 01:41 PM
  5. Replies: 1
    Last Post: 04-23-2018, 09:43 AM
  6. Replies: 19
    Last Post: 04-04-2016, 02:58 PM
  7. [SOLVED] Sumifs formula referencing cell generated by slicer/pivot table
    By 3345james in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-22-2015, 03:26 PM

Tags for this Thread

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