Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel 2003 PivotTable.ClearTable

Posted on 2010-11-09
2
Medium Priority
?
804 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

618 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