Delete All Pivot Tables with Excel VBA
This Excel VBA procedure will delete all of the pivot tables in a particular worksheet. It came in handy when I was devising the procedure to Create a Pivot Table with VBA. As once the procedure is run once the second time the procedure is run the code will fail unless the pivot tables is cleared.
Below is an example of what the pivot table delete code looks like.
Sub RemPiv() 'Excel VBA to Delete all pivot tables in a worksheet.
Dim Pt As PivotTable
For Each Pt In ActiveSheet.PivotTables
While the Excel VBA procedure looks very simple, it is very effective.