ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all pivot tables on a sheet (https://www.excelbanter.com/excel-programming/355326-delete-all-pivot-tables-sheet.html)

puff

Delete all pivot tables on a sheet
 
I make a copy of a sheet containing a number of pivot tables and then
try to delete the existing pivot tables on the new sheet with:

Sub PivotTableClearActiveSheet()
Dim p As PivotTable

With ActiveSheet
For Each p In .PivotTables
p.TableRange2.Delete
Next p
End With
End Sub

I get the following message:

Run-time error '1004':
You cannot change , move a part of, or insert cells ...

Any clues as to what I'm doing wrong.


puff

Delete all pivot tables on a sheet
 
Should have been

p.TableRange2.Delete xlShiftUp



All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com