+ Reply to Thread
Results 1 to 7 of 7

For each pivot item in pivot table - for data model

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    For each pivot item in pivot table - for data model

    I have a sheet with some 'normal' pivots, as well as a couple of data models (for the distinct count feature).

    I have some code which loops through the pivot items and selects the one that matches my string. This works fine for the normal pivots, but I can't get it to work for the data model ones - it throws up an error of 'Object doesn't support this property or method'. Any help/suggestions welcome!


    Please Login or Register  to view this content.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: For each pivot item in pivot table - for data model

    Hi,

    You forgot the .Pivotitems on the end of that line.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: For each pivot item in pivot table - for data model

    Ah, thank you!

    This certainly clears the error, but now when I step through the code it jumps straight from the line that had the error, to the next line of code immediately after Next, as though it can't actually find any pivot items. Not sure if this has anything to do with the fact that in the data model filter you have to click the + to expand the list first before you can manually select/deselect items?

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: For each pivot item in pivot table - for data model

    If you expand the list manually, does the code then loop through the items?

  5. #5
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: For each pivot item in pivot table - for data model

    It's not possible to expand the list whilst running the code - as soon as you select something other than the filter selection box it deactivates it and it reverts back to the condensed list.

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: For each pivot item in pivot table - for data model

    Can you post a sample workbook and clarify which version of Excel you are actually using- it's clearly not 2003 or 2007.

  7. #7
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: For each pivot item in pivot table - for data model

    Apologies - it's 2010. I don't have a sample workbook - would have to knock one up due to the financial data I'm using. Bear with

    Edit: there you go. This file/pivots and code is doing exactly what my 'real' file is doing. Runs through with no errors, but won't actually filter on the data model pivot.

    As an addition to this, I have an if statement now in my code that either has the 'Import' as one singular field ("A", "B", "C"), or turns it into an array (Three different arrays depending on criteria). If I'm filtering a pivot on a single item, no problem, but it's not that simple with an array. I've been looking at the code Jerry has suggested here, but not sure how to implement it for my own use.
    Attached Files Attached Files
    Last edited by dancing-shadow; 10-24-2017 at 09:20 AM.

+ 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. Add this data to the Data Model addition needed to current pivot table code
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2017, 06:52 PM
  2. VBA filter Pivot Table basen on Data Model
    By zico8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2017, 04:31 AM
  3. Creating a Pivot Table from Power Pivot Data Model?
    By nobodyukno in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2017, 12:02 PM
  4. Selecting Column Data in Pivot Table (from Data model)
    By derickz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2016, 11:35 PM
  5. power pivot table - Data model
    By pccamara in forum Excel General
    Replies: 2
    Last Post: 04-18-2016, 11:20 AM
  6. [SOLVED] Grouping disabled when pivot table is added to the data model?
    By Rvsalka in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-17-2015, 04:56 AM
  7. [SOLVED] Macro to update pivot item (date format) in pivot table to latest date from data source.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2012, 03:18 AM

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