Thread: Pivot Table
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
C. Roenbaugh C. Roenbaugh is offline
external usenet poster
 
Posts: 16
Default Pivot Table

I am trying to remove all data from a pivot table. The following code
does not work every time. I don't understand why.

Set PT = Worksheets("PT").PivotTables("PT1")

With PT
'clear old items
On Error Resume Next
.PivotFields("Data").Orientation = xlHidden
.RowFields(1).Orientation = xlHidden

'add row field
.AddFields RowFields:="LocationID"
'add the data filed
With .PivotFields("Amount")
.Orientation = xlDataField
.Function = xlSum
End With

End With