+ Reply to Thread
Results 1 to 2 of 2

PivotItem loop with getpivotdata - hide pivotitem

  1. #1
    Registered User
    Join Date
    12-04-2014
    Location
    Arlington, USA
    MS-Off Ver
    2010
    Posts
    12

    PivotItem loop with getpivotdata - hide pivotitem

    Hi,
    I'm trying to hide rows of a pivot table based on the sum of pivot items. The code works if I use the name of the pivot item in the getpivotdata function but does not work in a For Each PivotItem loop. Can you identify what I am doing wrong? The 1004 error occurs on line 1 of the loop
    Please Login or Register  to view this content.
    Example of Pivot Table example1.png
    Update at 2:30 pm: this is a filtered page. Code works on the main sheet. Now I'm trying to get it to work on the filtered pages where Company1 may not exist. The code fails when Company1 does not exist.
    Last edited by csutera; 01-11-2016 at 03:25 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: PivotItem loop with getpivotdata - hide pivotitem

    Without a workbook I can only speculate. One of the issues with pivot items is that at least one of them must be selected at all times. So say you have four items A, B, C, D and only B is turned off. You want to turn B off and C on. So you write code to do this. If you turn B off before turning C on, you will get an error. Something like this might be happening with your code. I can't tell without seeing the data.

    Generally, the way around this pitfall is to turn everything on, and then go back and selectively set what you want.

+ 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. need help with pivotitem loop. not working
    By clammastak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2015, 10:15 PM
  2. [SOLVED] Pivottable - cycle through each PivotItem
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2014, 05:22 AM
  3. Replies: 0
    Last Post: 06-14-2013, 12:33 PM
  4. VSTO - dynamic Hide/Unhide PivotItem OLAP.
    By zeric in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 01-31-2006, 10:06 AM
  5. [SOLVED] Set PivotItem using counter
    By CinqueTerra in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-02-2005, 01:40 PM
  6. PivotItem.Visible
    By Excelgeek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2005, 07:05 PM
  7. PivotItem positioning...
    By Jesterhoz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2005, 10:05 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