Solved

Excel 2003 PivotTable.ClearTable

Posted on 2010-11-09
2
736 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
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now