Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Delete pivot table

Hi
What is the syntax to delete a pivottable programatically? I tried

Dim ws As Worksheet
Dim pt As PivotTable

Set ws = ActiveWorkbook.Worksheets("unused")

Set pt = ws.PivotTables(1)
pt.Delete ' error
Set pt = Nothing

Thanks
Habib


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete pivot table

ws.PivotTables(1).DataBodyRange _
.CurrentRegion.EntireColumn.Delete


or .clearcontents



if there is data below the pivottable



set pt = ws.PivotTables(1)
ws.range(pt.pagerange,pt.databodyrange).Clear



--

Regards,

Tom Ogilvy



"HSalim[MVP]" wrote in message
...
Hi
What is the syntax to delete a pivottable programatically? I tried

Dim ws As Worksheet
Dim pt As PivotTable

Set ws = ActiveWorkbook.Worksheets("unused")

Set pt = ws.PivotTables(1)
pt.Delete ' error
Set pt = Nothing

Thanks
Habib




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Delete pivot table

Tom,
Thanks for the quick response. I took your example with a twist -
ws.PivotTables(1).DataBodyRange _
.CurrentRegion.EntireRow.Delete

Regards and Merry Christmas
Habib







"Tom Ogilvy" wrote in message
...
: ws.PivotTables(1).DataBodyRange _
: .CurrentRegion.EntireColumn.Delete
:
:
: or .clearcontents
:
:
:
: if there is data below the pivottable
:
:
:
: set pt = ws.PivotTables(1)
: ws.range(pt.pagerange,pt.databodyrange).Clear
:
:
:
: --
:
: Regards,
:
: Tom Ogilvy
:
:
:
: "HSalim[MVP]" wrote in message
: ...
: Hi
: What is the syntax to delete a pivottable programatically? I tried
:
: Dim ws As Worksheet
: Dim pt As PivotTable
:
: Set ws = ActiveWorkbook.Worksheets("unused")
:
: Set pt = ws.PivotTables(1)
: pt.Delete ' error
: Set pt = Nothing
:
: Thanks
: Habib
:
:
:
:


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to delete a row in the pivot table for the pivot chart babs Excel Discussion (Misc queries) 3 April 2nd 23 07:10 PM
Delete Pivot Table Formula sduffield Excel Discussion (Misc queries) 1 April 28th 10 10:24 PM
Delete some substotal in a pivot table Viv Excel Discussion (Misc queries) 1 February 20th 09 04:36 PM
Delete pivot table Zic[_2_] Excel Programming 2 May 25th 04 02:08 PM
Delete Pivot Table sapta Excel Programming 0 September 10th 03 05:07 AM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"