Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cycle through Pivot Tables with Pivot Items
All,
I am having a few problems. Situation: I have 20 Pivot tables. Most have Country Code and all have a staton code. I need my code to 1) Get the first country code 2) Update all Pivot tables where country code exists in the Pivot table 3) Print it 4) Next country code I have code to print the sheets to PDF And the code below changes only one of my tables (Though it shows it is referenceing all my tables) Any ideas? Code: Sub Internet() 'Got this off the internet Dim PI as PivotItem Dim PF as PivotField Dim I as Integer ' This allows the macro to run but still shows below it is doing something to a 'Pivot table where the item does not exsist On Error Resume Next I = 0 Set PF = Worksheets("Test").Pivotfields("Country Cd") For Each PT in worksheets("test").PivotTables For Each PI in PF.PivotItems PF.CurrentPage = PI.value If worksheet('test").Range("B12") = "0" then 'Do nothing No data for the country Else I = I + 1 'Test Junk Worksheets("sheet2").Cells(I,1) = PI.Value ' Sheet two lists all countrys with more than one record 20 times one for each pivot table ' even though it only changed one pivottable ' Add call to print here ' MsgBox "Working on " & PT 'This shows all the pivot tables one at a time even thought 'Its not doing anyting to them End IF Next Next PT End Sub So, how to get it to loop and how to avoid the pivot table with out Country Cd in it? Doug |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
pivot tables: Calculated fields among *row* items | Excel Discussion (Misc queries) | |||
Name items in Pivot Tables? | Excel Discussion (Misc queries) | |||
ticked items on Pivot tables | Excel Discussion (Misc queries) | |||
Pivot tables - calculated fields and items | Excel Discussion (Misc queries) | |||
show items with no data option in pivot tables | Excel Discussion (Misc queries) |