View Single Post
  #1   Report Post  
 
Posts: n/a
Default Reset a caption for a Pivot Table

Hello all,

Thanks for taking a look at this for me.

I have a worksheet with many pivot tables on it. A user has typed a
'0' over one of the data sets.

I need to get the 0 back to the original data.

Here is the tricky part: I want all my other captions to stay the
same, and this particualar field does not exsist in all my pivot
tables, so I need something like this:


Where the field "Departure Station" exsists then do this but only for
the filed Departure Station. This Macro fails when it gets to Pivot
table p20, because p20 does not have Departure Station.

Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim Sfld As String
Sfld = "Departure Station"


For Each pt In ActiveSheet.PivotTables
Set pf = pt.PivotFields(Sfld)
For Each pi In pf.PivotItems
pi.Caption = pi.SourceName
Next pi

pt.RefreshTable
Next pt


Any help would be great!

Thanks

Doug