Solved

Amend all Pivot Tables in Workbook

Posted on 2011-03-14
2
257 Views
Last Modified: 2012-08-14
Hi Experts!

Please help! I've got a workbook with lots of Pivot Tables, and would like to set the PivotFields and PivotItems across all of them.  I've specified the values in the code below, but I can't get this to run.

Thanks,

Steve
Sub AmendAllPivs()

Dim pt As PivotTable
    
    For Each pt In ActiveSheet.PivotTables

    pt.PivotFields ("Product Name")
        .PivotItems("0").Visible = False
        .PivotItems("DIS01").Visible = False
    pt.PivotFields ("LTV Band")
        .PivotItems("85").Visible = False
        .PivotItems("90").Visible = False
        .PivotItems("95").Visible = False
        .PivotItems("100").Visible = False
        .PivotItems("0").Visible = False
    End With
    Next pt

End Sub

Open in new window

0
Comment
Question by:scsnow2310
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 50 total points
ID: 35129445
You are missing With..End With blocks:
Sub AmendAllPivs()  
  
Dim pt As PivotTable  
      
    For Each pt In ActiveSheet.PivotTables  
  
    With pt.PivotFields ("Product Name")  
        .PivotItems("0").Visible = False  
        .PivotItems("DIS01").Visible = False
    End With
    With pt.PivotFields ("LTV Band")  
        .PivotItems("85").Visible = False  
        .PivotItems("90").Visible = False  
        .PivotItems("95").Visible = False  
        .PivotItems("100").Visible = False  
        .PivotItems("0").Visible = False  
    End With  
    Next pt  
  
End Sub

Open in new window

0
 

Author Closing Comment

by:scsnow2310
ID: 35130483
Many thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now