?
Solved

Excel 2003 PivotTable.ClearTable

Posted on 2010-11-09
2
Medium Priority
?
790 Views
Last Modified: 2012-05-10
My spreadsheet has a pivot table on 5 different worksheets.  Two of the pivot tables use the same datasource. The others each have their own datasource.

For the 2 tables that share the same datasource I get a warning message when I run pvtTable.ClearTable.  The message is:
The pivottable report is based on the same data as at least one other pivottable report. Clearing the pivottable report will remove the following from all the pivottable reports: grouping, calculated items, calculated fields, custom items.
See attached .jpg


Dim arrColumns
    Dim nColumns As Integer
    Dim wsReport, wsData As Worksheet
    Dim pvtTable As PivotTable
    
    Application.ScreenUpdating = False
    
    Set wsReport = Worksheets(sReportType)
    Set wsData = Worksheets(sReportType & "Query")
    theDataSource = sReportType & "Results"
   
    'Put the Column Headings of the Query Results into an array
    wsData.Select
    col = Range("A1").End(xlToRight).Select
    nColumns = Selection.Column
    ReDim arrColumns(nColumns - 1)
    For i = 0 To nColumns - 1
        arrColumns(i) = Cells(1, i + 1).Value
    Next
    
    'Clear the old pivot table and place the pivot table fields
    wsReport.Select
    Set pvtTable = wsReport.Range("A10").PivotTable
    
    pvtTable.ClearTable                 'this is the line that causes the message

Open in new window

pivottable-warning.jpg
0
Comment
Question by:CarenC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 34096098
Try turning Application.DisplayAlerts off (by setting it to False) prior to clearing your table.

Brad
Sub PTdeleter()
Dim pt As PivotTable
Application.DisplayAlerts = False
For Each pt In ActiveSheet.PivotTables
    pt.ClearTable
Next
Application.DisplayAlerts = True
End Sub

Open in new window

0
 

Author Closing Comment

by:CarenC
ID: 34096588
Thanks.  Didn't know that code.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question