+ Reply to Thread
Results 1 to 8 of 8

Pivottable Cubefield vs PivotField

  1. #1
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Pivottable Cubefield vs PivotField

    Hi guys.

    Ok, so here is a weird one that I'm experiencing today.

    I have a workbook with a pivottable and have written some macro code which would execute successfully.
    I previously referred to pivotfield, but today the file is looking for a reference to cubefield.

    Is there some kind of setting in the options that I may have inadvertently turned on/off which now refers to pivotfields as cubefields?

    I can't upload the file here, but here is some info:
    I download the file from a central server, and click a refresh button (which I think refreshes data connections).
    Prevoiusly, my code referred to the pivottable fields and it worked fine.
    Today, the code doesn't want to execute correctly so I then went and used the macro recorder which gave me this code:

    Please Login or Register  to view this content.

    I see that it refers to cubefields.
    So I'm going through the code in VBA to replace references to cubefields instead of pivotfields.

    Any thoughts on this?
    What is the difference between a cubefield and pivotfield?
    Why does it now refer to cubefields?
    Why doesn't pivotfield work? Do you have to always use cubefiled OR pivotfield?


    Thanks in advance.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Pivottable Cubefield vs PivotField

    Did your cube data get changed?
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Pivottable Cubefield vs PivotField

    Yes, the cube data gets updated each month. I don't actually know anything about cubes but this is a report which gets updated at the end of each month.
    I can see 5 data connections when I click on Data -> Connections.

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Pivottable Cubefield vs PivotField

    You do not say what error you were having but I think probably the cube fields were changed in some way. I do not think you must use Cubefields instead of PivotFields for this code - only if you wish to access properties or methods that belong only to cubefields.

  5. #5
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Pivottable Cubefield vs PivotField

    Initially, I had an "on error resume next" line in the code, so it would execute to the end but the outputs looked all wrong (pivotfields not in the arrangement that the code was supposed to execute on).

    So I "texted it out" and then I got the error - "Run time 1004: Item name cannot be found..."

    Then when clicking the debug button, it highlights a line which refers to pivotfield.
    When I change this code to refer to cubefield then the code runs ok.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Pivottable Cubefield vs PivotField

    I think perhaps the name or caption of the field in the field list is different from the text in your code?

  7. #7
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Pivottable Cubefield vs PivotField

    Had to go back and change the code in a few places, and learnt that the syntax for cubefields can be quite different to the syntax for pivotfields.

    You can't do subtotals on cubefields, you have to reference pivotfield eg.

    Please Login or Register  to view this content.
    When doing the subtotal, you have to state the field name twice as above.
    When bringing int he field to a pivot, you have to state it once:

    Please Login or Register  to view this content.
    When adding a data field, it looks like this

    Please Login or Register  to view this content.
    Turned out to be quite a pain in the a$$.

    I think there is some kind of background setting that I turned on by mistake,
    The reason I say this is because I took a report from 2 months ago (where my old code worked fine), and that old file is also "looking" for Cubefield references.

  8. #8
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127

    Re: Pivottable Cubefield vs PivotField

    Quote Originally Posted by Izandol View Post
    I think perhaps the name or caption of the field in the field list is different from the text in your code?
    The caption was exactly the same And it wasn't a calculated field either.

+ 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. VBA & PivotField Code
    By rrhutch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2021, 11:23 PM
  2. PivotTable Sum with Calculated PivotField
    By ShredDude in forum Excel General
    Replies: 0
    Last Post: 10-22-2010, 11:30 PM
  3. How to get the PivotField i've clicked on?
    By opc10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-19-2007, 05:38 PM
  4. [SOLVED] How to have a Macro skip code if PivotTable/PivotField is not there
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2006, 07:40 AM
  5. CubeField Member Properties for Excel 2k?
    By Jérémie Gent in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2005, 05:05 AM

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