+ Reply to Thread
Results 1 to 17 of 17

VBA: Filtering Power Pivot - Visible Item

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    VBA: Filtering Power Pivot - Visible Item

    Wasn't sure if this should be here or in VBA

    I've started using power pivots rather than regular pivots and the way I previously used to filter using VBA doesn't work. The code below gets as far as clearing filters ok but the next part which is checking each item for a specific string doesn't do anything, Neither of the message boxes I've put in popup.

    Please Login or Register  to view this content.

  2. #2
    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,903

    Re: Filtering Power Pivot - Visible Item

    You can use an array to filter, like this:

    Please Login or Register  to view this content.
    Rory

  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: Filtering Power Pivot - Visible Item

    Thanks Rory, I seem to be getting a similar issue though. The code runs without any error but the pivot is left with all items visible.

  4. #4
    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,903

    Re: VBA: Filtering Power Pivot - Visible Item

    It works fine for me here. Do you have any error handling in place? Are you sure there are items that match (note that Like is case sensitive).

  5. #5
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    I've just copy/pasted your code into a new VBA sub, changed pivottable2 to pivottable3 and ran it.

    There are over 1000 *INC* matches when I filter the pivot manually. For some reason with my pivot/data it's not finding anything as sticking a
    Please Login or Register  to view this content.
    at the end is also blank.

    If I record a macro of me running a manual filter here's a snap of the output.

    Please Login or Register  to view this content.

  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,903

    Re: VBA: Filtering Power Pivot - Visible Item

    If you step through the code is it finding any matches?

  7. #7
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    Quote Originally Posted by rorya View Post
    If you step through the code is it finding any matches?
    Nope, It doesn't even touch the first IF.

  8. #8
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA: Filtering Power Pivot - Visible Item

    Are you sure the table is not actually called Range2, rather than Range 2?

  9. #9
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    Quote Originally Posted by Bob Phillips View Post
    Are you sure the table is not actually called Range2, rather than Range 2?
    Hi Bob, It's definitely 'Range 2' as shown when I manually record a filter macro.

  10. #10
    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,903

    Re: VBA: Filtering Power Pivot - Visible Item

    Which version of Excel are you actually using?

  11. #11
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    Quote Originally Posted by rorya View Post
    Which version of Excel are you actually using?
    I'm running 2016.

  12. #12
    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,903

    Re: VBA: Filtering Power Pivot - Visible Item

    I've only got 2010 available here, so I'll try and verify the code on 2016 later on.

  13. #13
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32
    Quote Originally Posted by rorya View Post
    I've only got 2010 available here, so I'll try and verify the code on 2016 later on.
    Thanks again.

  14. #14
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: VBA: Filtering Power Pivot - Visible Item

    Quote Originally Posted by rorya View Post
    I've only got 2010 available here, so I'll try and verify the code on 2016 later on.
    I already did Rory, it works for me on 2016.

  15. #15
    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,903

    Re: VBA: Filtering Power Pivot - Visible Item

    Thanks, Bob - saves me trying to find a working VM!

  16. #16
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    Thanks, guys.

    I'll rebuild my data and try the code again.

  17. #17
    Registered User
    Join Date
    02-06-2013
    Location
    Sheffield
    MS-Off Ver
    2007
    Posts
    32

    Re: VBA: Filtering Power Pivot - Visible Item

    Thanks for all your help.

    I've recreated the data range on another sheet and have the same issue. It's not easy for me to cleanse the data to upload so I'll have to go back to regular pivots for now.

+ 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. Power Pivot - Filtering flowing down from separate table
    By Jonny757 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-18-2018, 02:44 PM
  2. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  3. Pivot item filtering performance with VBA
    By domlep in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-26-2017, 09:31 AM
  4. Replies: 0
    Last Post: 02-04-2015, 11:38 AM
  5. Table Object after filtering - Count visible rows & First visible row
    By limalf in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2013, 07:29 PM
  6. Macro for selecting a single item while filtering the data in Pivot Table
    By Syed964 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 01:28 PM
  7. Why do Pivots display pivot item tick boxes that are not visible in the pivot?
    By davellll in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2009, 12:53 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