Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to have a Macro skip code if PivotTable/PivotField is not there

Excel 2003 connected to an OLAP database. I am updating a PowerPoint
presentation that has 40 different PivotCharts in it. In these Charts
some have one Pivot Table others have two Pivot Tables. These charts
are updated monthly with different customer names and date ranges or
other varables.

I am trying to find a way to have the Macro look to see if this
PivotTable or PivotField is present if not then skip the code for it.
The Table names are all different. The Macro runs fine as long as the
charts have two pivot tables it errors out on the ones that only have
one Pivot Table. If I comment out the line for the second pivot table
it also runs fine but only updates the information in one pivot table.
This Macro is set up to loop through all the slides and update the
fields with the information I specify.

I have been trying to use an If Then statement but I have not been able
to get it to work, even the "On Error Resume Next" does not work.

Any Suggestions, I have only been playing around with Macros for a few
months so it is probally something I am overlooking.

Here is part of the Macro. The Macro was orginaly written by someone
else to update the database connections I am just modifing it to cut
down on the amount of time spent to generate these reports. Currenlty
each chart has to be opened and the fields manually changed. The
coding below has been gathered from me recording my actions in the
charts or from searching Google.

Dim aSheet As Object, aPivot As Object,
.....

If TypeName(aSheet) = "Worksheet" Then

For Each aPivot In aSheet.PivotTables
'Debug.Print aSheet.PivotTables(1).Name

On Error Resume Next

aSheet.PivotTables(1).PivotFields("[Platinum Name]").CurrentPageName =
"[Platinum Name].[All Platinum Name].[xxxx]"

aSheet.PivotTables(2).PivotFields("[Platinum Name]").CurrentPageName =
"[Platinum Name].[All Platinum Name].[xxxx]"

'Shows just three months of data from Oct to Dec

aSheet.PivotTables("PivotTable1").CubeFields(4).Tr eeviewControl.Drilled
= Array(Array(""), Array( _
'"[Date Closed Calendar].[All Date Closed
Calendar].[2005]"), Array("[Date Closed Calendar].[All Date Closed
Calendar].[2005].[Quarter 4]"))


aSheet.PivotTables("PivotTable1").CubeFields(4).Tr eeviewControl.Drilled
= _
Array(Array(""), Array( _
"[Date Closed Calendar].[All Date Closed Calendar].[2005]"),
Array( _
"[Date Closed Calendar].[All Date Closed
Calendar].[2005].[Quarter 4]"))
aSheet.PivotTables("PivotTable1").PivotFields("[Date Closed
Calendar].[Year]") _
.HiddenItemsList = Array("[Date Closed Calendar].[All Date
Closed Calendar].[]" _
, "[Date Closed Calendar].[All Date Closed Calendar].[2003]", _
"[Date Closed Calendar].[All Date Closed Calendar].[2006]", _
"[Date Closed Calendar].[All Date Closed Calendar].[2004]")
aSheet.PivotTables("PivotTable1").PivotFields( _
"[Date Closed Calendar].[Quarter]").HiddenItemsList = Array( _
"[Date Closed Calendar].[All Date Closed
Calendar].[2005].[Quarter 1]", _
"[Date Closed Calendar].[All Date Closed
Calendar].[2005].[Quarter 2]", _
"[Date Closed Calendar].[All Date Closed
Calendar].[2005].[Quarter 3]")
aSheet.PivotTables("PivotTable1").PivotFields("[Date Closed
Calendar].[Month]" _
).HiddenItemsList = Array("")

Next aPivot

Thanks for any help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to change the PivotField to sum Vick Excel Discussion (Misc queries) 3 December 21st 05 10:34 PM
Hiding a pivotfield using code Todd Huttenstine Excel Programming 1 June 10th 04 05:01 PM
Excel VBA macro - need to edit code to skip a year adun3434 Excel Programming 0 April 1st 04 09:14 PM
PivotTable, Pivotfield selective invisible, too slow MSN Excel Programming 0 November 11th 03 10:56 AM
Code for Grouping Text Values in Pivotfield Keith Young Excel Programming 1 July 17th 03 03:14 AM


All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"