Pivot table is a very useful and powerful functionality for summarizing or calculating data in Excel, So we may usually insert Pivot tables into a worksheet or multiple worksheets.But, Sometimes we need to delete all pivot tables from active workbook to create brand new pivot tables which Target new data and design. It will be a very time consuming task to delete all pivot table from workbook which contains large number of pivot table created.
Do you know how to delete all pivot tables in the whole workbook?
Here is the code which is very useful to delete all pivot tables from active workbook.
' Author: Dreams24
' Written for VBA Tricks and tips blog
Dim pt As PivotTable
Dim ws As Worksheet
'For loop through each worksheets
For Each ws In ActiveWorkbook.Worksheets
'Loop to select each pivot table for a single worksheet
For Each pt In ws.PivotTables
'Delete a selected pivot table on worksheet
pt.PivotSelect "", xlDataAndLabel, True
'Exit Sub 'Optional: Get out