+ Reply to Thread
Results 1 to 7 of 7

Macro to Run when Slicer Selection is Changed (multiple slicers)

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Macro to Run when Slicer Selection is Changed (multiple slicers)

    Hi All,

    I was searching for a way to run macro whenever I select an item on a slicer or whenever the selection is changed. The closest I found was the thread below.

    http://www.excelforum.com/excel-prog...s-changed.html

    Since I'm new to this I don't know where to put the macro and how to apply it on multiple slicers. The first Slicer has a category and the other has the sub category. I need it to run every time selection is changed on either slicer.

    This is the macro I want to run if it helps.

    Please Login or Register  to view this content.
    Last edited by jcanlas; 01-26-2015 at 10:41 AM.
    JCANLAS

  2. #2
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,144

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    Hi,

    Put your macro code in a Module level procedure and assign that macro to the slicer
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    Hi Richard,

    Thanks for the quick response. However, what I meant was for the macro to run on selection change. I may have confused you with the macro name (Macro1_Click) since I obtain that code by recording the macro when an object is clicked. Currently, the macro runs when the button/object is clicked. I want to eliminate the button click and have it built in when Slicer selection is changed.

    I hope I explained it clear.

    Edit: I just realized that I did not proof read the question before I posted it. Original post edited.
    Last edited by jcanlas; 01-26-2015 at 10:39 AM.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    Assuming you are controlling a pivot table on the same sheet, use the Worksheet's PivotTableUpdate event. Right-click the sheet tab, choose View Code and paste this in:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,144

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    No, you've explained it clearly. Except that there seems a contradiction since you mention the macro running on selection change and then later when the slicer is changed. Maybe you mean the two are the same things but it's confusing since the term Selection Change has a quite specific meaning in VBA, i.e. it refers to a Sheet

    As I understand it when you pick a new slicer value you want the macro to run. If so that's what the code I gave you will do.

    Upload the workbook with the code I gave if you think it's not working. The code needs to go in a module level procedure which is assigned to the Slicer object.

  6. #6
    Registered User
    Join Date
    10-04-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    Thanks Rory!

    Exactly what I needed.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-18-2021
    Location
    HK
    MS-Off Ver
    excel 2010
    Posts
    1

    Re: Macro to Run when Slicer Selection is Changed (multiple slicers)

    i would like to thank you rompterstomper this works perfectly! thanks for the community your post is valuable even in 2021!

+ 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. [SOLVED] Macro to Run when Slicer Selection is Changed
    By MBeedle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2017, 09:29 AM
  2. [SOLVED] Pivot Slicers from multiple Caches - problem with 2nd Slicer displaying incorrect data
    By matt4003 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-14-2013, 03:06 AM
  3. Limiting Slicer multiple selection
    By Paul-NYS in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 12-17-2012, 02:58 PM
  4. Slicer Macro - unfilter another slicer on selection
    By chadheins in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2012, 10:41 AM
  5. [SOLVED] Max five selection in slicers
    By Reykjavik in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-27-2012, 03:26 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