+ Reply to Thread
Results 1 to 3 of 3

Losing Fields when clearing a Pivot Table

Hybrid View

jomili Losing Fields when clearing a... 08-11-2014, 08:30 AM
humdingaling Re: Losing Fields when... 08-12-2014, 01:46 AM
jomili Re: Losing Fields when... 08-13-2014, 08:49 AM
  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,169

    Losing Fields when clearing a Pivot Table

    Our QA team creates a workbook which contains a pivot table linked to an external data source. My team has no link to the datasource, other than through the pivot table. We can reconfigure the pivot any way we want.

    Our team has to use the pivot table to do a comparison with another data source. To enable the comparison, we have to reconfigure the Pivot table. Since there's a lot of fields to reconfigure, and there are 10 of us throughout the state, and we each have to do it daily, I've written a macro to do it for us. It moves/brings in/out the fields we need.

    My macro works well, except when the QA changes the "look" of the pivot table for their purposes. So all of a sudden my macro bombs because an expected field isn't where it used to be.

    I thought I had an answer to this problem with the below code:
    ActiveSheet.PivotTables(1).ClearTable
    My thought was that I could clear the pivot, and rebuild it with the constituant fields, to make it the way I want it, no matter what changes the QA team does.

    But, I have a problem; when I first go into the pivot table, there's a field (FUND_PosnFunc) that is critical to the data I need to extract. But, if I run the above code, while most other fields remain, the FUND_PosnFunc field disappears.

    So, my question is, how can I both clear the pivot field AND retain all the fields it had before I cleared it?

    Thanks in advance.

    BTW, it doesn't help if you tell me to tell the QA team not to make changes. If it was that easy I would have done it long ago.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Losing Fields when clearing a Pivot Table

    could you not cleartable and re-add the field?

        ActiveSheet.PivotTables(1).ClearTable
        ActiveSheet.PivotTables(1).CalculatedFields.Add "FUND_PosnFunc", "=Marks /100", True
    i just random simple field marks/100 in my example
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,169

    Re: Losing Fields when clearing a Pivot Table

    Never mind, I'm just being stupid. The field IS there, it just has a different name. I'm okay now. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Change PIVOT source and NOT losing calculated fields
    By kaligad in forum Excel General
    Replies: 0
    Last Post: 11-28-2013, 08:50 AM
  2. Collapse/Expand - Pivot table Fields - Need equivalent option in Excel VBA Pivot table
    By ragavendraph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2012, 03:00 PM
  3. Pivot table losing column fields when run from macro
    By medeng in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2012, 11:15 AM
  4. How to Disable automatic fields in pivot table like total and count on fields
    By anushka in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2009, 07:53 AM
  5. Differentiate between column fields and data fields in a pivot table
    By whiteheadw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2009, 01:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1