PDA

View Full Version : Solved: Pivot Table VBA problem - simple ?



s.schwantes
10-17-2008, 11:16 AM
I'm building pivots using the macro recorder and VBA. One of my tables ends up w/ a field w/ 7 items in it sorted alpha / ascending. I'm setting the advanced properties for the field to "manual" - which allows you to drag the row to a different position in the table - manually. I've done this via the recorder, but every time I run the macro, it craps out on me, w/ the following error message: Runtime error 1004 - "Unable to set the position property of the Pivot Item class." I've got the following rows in my table:

Contract Manufacturing Cost of Production Net PPV Resource Absorption - System WIP Variances - Material WIP Variances - Resource

I want to move Net PPV to position 7, i.e., the last row.

Here's the VBA code:


Range("A36:D36").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Account Roll Up - Trended COGS").PivotItems("Net PPV").Position = 7



The range is A - D as I have the rows shown above are in A, and then I have 3 columns of data to the right, e.g., Q1, Q2, Q3.

Any ideas or suggestions would be welcome. It would be nice to automate moving this row for PPV, but not the end of the world if it's just not possible to do w/ VBA.

Thanks!!

SS

:dunno

s.schwantes
10-17-2008, 11:17 AM
by the way it was suppose to look like this:

contract mfg
cost of prod
net ppv
etc
etc
etc

not all on the same row as above

thks,

ss

s.schwantes
10-17-2008, 11:27 AM
I got it ... d'oh!

I changed 7 to 6, and that worked. For some reason the recorder records the position as 7, but once I changed it to 6 ... it works.

Ciao