Macro to delete Pivot Tables


Delete all Pivot tables in the active Worksheet


Sub DeletePivotTablesInActiveSheet()
Dim PT As PivotTable
For Each PT In ActiveSheet.PivotTables
PT.TableRange2.Clear
Next PT
End Sub

Delete all Pivot tables in the active Workbook


Sub DeleteAllPivotTables()
Dim PT As PivotTable
Dim Ws As Worksheet
For Each Ws In Sheets
For Each PT In Ws.PivotTables
PT.TableRange2.Clear
Next PT
Next Ws
End Sub

How to use codes shared here?