PC Review


Reply
Thread Tools Rate Thread

Cycle through Pivot Tables with Pivot Items

 
 
douglascfast@hotmail.com
Guest
Posts: n/a
 
      15th Oct 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro on pivot tables / pivot items markx Microsoft Excel Programming 12 9th May 2008 07:06 PM
Building pivot tables in Excel 2007 based on existing pivot tables? jj.jigga.johns@gmail.com Microsoft Excel Misc 4 26th Dec 2007 08:05 PM
Updating pivot items on 3 pivot tables contained on one sheet =?Utf-8?B?a2x5c2VsbA==?= Microsoft Excel Programming 2 9th Aug 2007 07:00 PM
Updating pivot items in three pivot tables on one sheet via VBA =?Utf-8?B?a2x5c2VsbA==?= Microsoft Excel Programming 0 8th Aug 2007 07:20 PM
How does the term 'pivot' apply to Excel's Pivot tables and Pivot. =?Utf-8?B?c3R2ZXJtb250?= Microsoft Excel Misc 1 17th Feb 2005 01:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:18 AM.