+ Reply to Thread
Results 1 to 4 of 4

Macro to hide all row values in Pivot Table?

  1. #1
    Registered User
    Join Date
    05-10-2016
    Location
    Bratislava
    MS-Off Ver
    2013
    Posts
    23

    Post Macro to hide all row values in Pivot Table?

    Hello forum,

    I would like to create a Macro that would deselect all row values in a Pivot Table and then select only one specific value.

    The reason I need this specifically is simple: as each month, new values are added into the excel file and pivot table, I cannot update the Macro each month to deselect a specific value.

    This is what I have so far:

    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Building ID")
    .PivotItems("Building ID").Visible = True
    ' above is the value I want to make visible
    End With

    ' below are the values I want to hide. These are just five of the approx. 180 values I have to hide. So the Macro itself is unnecessarily long as well
    With ActiveSheet.PivotTables("PivotTable5").PivotFields("Building ID")
    .PivotItems("Building ID 1").Visible = False
    .PivotItems("Building ID 2").Visible = False
    .PivotItems("Building ID 3").Visible = False
    .PivotItems("Building ID 4").Visible = False
    .PivotItems("Building ID 5").Visible = False


    Many thanks for helping me out with this one!

    Best regards,
    Adam

  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: Macro to hide all row values in Pivot Table?

    Hi

    You might use a filter instead
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    05-10-2016
    Location
    Bratislava
    MS-Off Ver
    2013
    Posts
    23

    Re: Macro to hide all row values in Pivot Table?

    Hi xlnitwit,

    many thanks for your response

    It indeed works, the only issue I have with this is that when I look at the filter, all row values seem to be selected (eventhough I'm of course only able to see the Building ID value). Why is that?

    Additionally, with this method I'm only able to select one value at a time. Let me explain:

    For each row value, there is a separate macro. For example, if I want Excel to show me Building ID 2, Building ID 6 and Building ID 12, with this method it's not possible to add another Building ID.

    Is there a workaround for that?

    Many thanks again!

    Cheers,
    Adam

  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: Macro to hide all row values in Pivot Table?

    The answer is specific to the question you asked. It can be expanded for two items, but for more than that you would need to loop through the pivot items and hide them based on the name.

+ 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. Help with Pivot table macro to hide/unhide pivot fields
    By indigo7 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-05-2014, 11:39 AM
  2. [SOLVED] Macro to hide rows in pivot table if values in row C&D are both 0
    By nhouse20 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2012, 10:09 AM
  3. how to hide 0 values in pivot table
    By maryj in forum Excel General
    Replies: 4
    Last Post: 05-25-2011, 01:46 PM
  4. [SOLVED] How do I hide rows in a pivot table with zero values?
    By fs in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-22-2006, 04:15 PM
  5. [SOLVED] How do i hide rows in pivot table that has zero values?
    By SHIAN in forum Excel General
    Replies: 0
    Last Post: 11-02-2005, 06:20 PM
  6. [SOLVED] How do i hide rows in pivot table that has zero values?
    By SHIAN in forum Excel General
    Replies: 0
    Last Post: 11-02-2005, 06:17 PM
  7. hide 0 values in pivot table (2003)
    By Tim in forum Excel General
    Replies: 1
    Last Post: 05-15-2005, 11:06 PM

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