+ Reply to Thread
Results 1 to 4 of 4

Disconnect Slicers, Change Pivot Table Source, Reconnect Slicers: a problem

  1. #1
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Disconnect Slicers, Change Pivot Table Source, Reconnect Slicers: a problem

    Hello,

    I have run into the problem of not being able to programmatically do the following: a) disconnect pivot table slicers; b) change pivot table source (different workbooks); c) reconnect slicers.

    I need this because depending on what users want to see, different pivot table data needs to be loaded but I can't change the pivot table source without disconnecting the slicers first.

    All pivot tables in this workbook have the same pivot cache.
    There are 4 slicers ("Slicer_Office", "Slicer_Week", "Slicer_Name", "Slicer_Name1"), 2 of which connect to tall pivot tables in the wb, and 2 of which connect to different tables.

    I've looked elsewhere in the forum and have found something that looks like it should work but I only get errors when I try to run it.

    Here is the most promising code I have found so far: Excel forum thread

    Here is how Izandol's code looks when I try to adapt it for my use (but I get an error):
    Please Login or Register  to view this content.
    So far I get an "Run-time error '5': Invalid procedure call or argument" error at line:
    Please Login or Register  to view this content.
    Please help me,

    Geoff.

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

    Re: Disconnect Slicers, Change Pivot Table Source, Reconnect Slicers: a problem

    You've already included 'Slicer_' in the names in the array so you don't need to add it again. It should be:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Disconnect Slicers, Change Pivot Table Source, Reconnect Slicers: a problem

    Hmm, that was obvious.. thanks!

    I was hoping that was the only error but...
    Any chance you spot why I get the "reference not valid error" at this line?:
    Please Login or Register  to view this content.
    Do you think its this part: "SourceData:=sNewSource?" In the original post where I found this code, it was like this:
    Please Login or Register  to view this content.
    Here is the code in full again (with the 'string_' removed):
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Disconnect Slicers, Change Pivot Table Source, Reconnect Slicers: a problem

    So I patched up something that works after trying a few things out with more code I found online. The working code is below.

    I have run into a new problem, this codes disconnects all slicers from all pivot tables and reconnects all slicers to all pivot tables; in my case, not all my slicers (I have 4 of them) connect to all my pivot tables so I need to figure out to select the pivot tables that each slicer connects to individually. I will ask this question in a new post if I can't figure it out myself.

    Here's what it looks like and it does work although it is fragmented and can surely be simplified by someone more adept than I with VBA:
    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. [SOLVED] How do i change SourceData for all pivots in workbook while disconnect/connect slicers?
    By andygxxxv in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-04-2016, 10:15 AM
  2. VBA to change pivot slicers based on cell values
    By Samantha McNeill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2014, 08:57 PM
  3. Replies: 0
    Last Post: 11-12-2014, 08:39 AM
  4. How do I stop slicers resetting row heights in the pivot table?
    By MattAkers in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-18-2014, 09:21 AM
  5. Use combobox value to filter Pivot Table like slicers using VBA
    By limalf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2013, 07:31 PM
  6. Can you have pivot table fields as slicers?
    By no.18shirt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2013, 05:12 PM
  7. Can you have pivot table fields as slicers?
    By no.18shirt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-19-2013, 10:39 AM

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