DISCOVER
×

How to delete a pivot table in vba

Updated July 20, 2017

A pivot table is used to summarise data and is commonly used in spreadsheet programs such as Microsoft Excel. Visual Basic for Applications is a computer programming language developed by Microsoft and used to automate routine tasks in Microsoft Office applications. You may need to write VBA code to delete pivot tables if you have a workbook with a lot of worksheets and you need to manually delete them. In a few steps you may write VBA code to delete a pivot table.

Start Microsoft Office Excel and type "Columns" in "A1", "Data" in "B1", "Field" in "A2", "12" in "B2", "Field2" in "A3", and "13" in "B3".

Click "A1", press "Ctrl" and "A," click the "Insert" menu and select "PivotTable." Click "OK."

Check the boxes next to "Columns" and "Data."

Select the "Developer" tab, then click "Visual Basic." Click the "Insert" menu and select "Module."

Copy and paste the code below into your new module to delete the pivot table you have just created.

Private Sub deletePivotTable()

End Sub

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Jaime Avelar is a professional writer whose programming articles appear on various websites. He has been a software programmer since 2000. Avelar holds a Master of Science in information systems from the University of Texas at Arlington.