Remove specific Pivotcache fields

D

Dan Bayliss

Hello all

I'm attempting to have VBA code to remove specific Pivotcache fields

basically currently i have the following

Name | Sales
Bob | 5
Dave | 3

Now the name field shows even if blank, so if i clear the sales data
and refresh i still see the list of names

What i ideally want todo is to clear just the number of sales, so each
time the sheet is opened it has blank number of sales

Any ideas/suggestions would be really appreciated!

I tried the following with no luck
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
For Each pf In pt.VisibleFields
For Each pi In pf.PivotItems
If pi = "Sales" Then
pi.Delete
End If
Next
Next
Next
Next
 
Top