ziad alsayed
Well-known Member
- Joined
- Jul 17, 2010
- Messages
- 665
dear all
how can i delete all pivot tables in a workbook
apprreciate any help.
how can i delete all pivot tables in a workbook
apprreciate any help.
Hi sir
What if I want to delete only specific Pivot table in my active sheet.
[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]
[color=darkblue]Sub[/color] DeleteSpecificPivotTables()
[color=darkblue]Dim[/color] Wks [color=darkblue]As[/color] Worksheet
[color=darkblue]Dim[/color] PT [color=darkblue]As[/color] PivotTable
[color=darkblue]If[/color] ActiveWorkbook [color=darkblue]Is[/color] [color=darkblue]Nothing[/color] [color=darkblue]Then[/color]
MsgBox "There is no active workbook!", vbExclamation, "ERROR!"
[color=darkblue]Exit[/color] [color=darkblue]Sub[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]For[/color] [color=darkblue]Each[/color] Wks [color=darkblue]In[/color] ActiveWorkbook.Worksheets
[color=darkblue]For[/color] [color=darkblue]Each[/color] PT [color=darkblue]In[/color] Wks.PivotTables
[color=darkblue]Select[/color] [color=darkblue]Case[/color] PT.Name
[color=darkblue]Case[/color] "PivotTable1", "PivotTable2", "PivotTable3"
PT.TableRange2.Clear
[color=darkblue]End[/color] [color=darkblue]Select[/color]
[color=darkblue]Next[/color] PT
[color=darkblue]Next[/color] Wks
[color=darkblue]End[/color] [color=darkblue]Sub[/color]