PC Review


Reply
Thread Tools Rate Thread

Code problems for pivot table

 
 
Chris Freeman
Guest
Posts: n/a
 
      23rd Jun 2009

Hi there,
I created a pivot table and captured the keystrokes as a recorded macro. But
now when I re-run the code, I get error message 1004: Unable to get the
PivotItems property of the PivotField class. the lspecific line that fails:
ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems("Sum of
Value").Position = 1

The problem results in crerating the pivot tables, but the coulms come out
with a Count of Values instead of Sum of Values.

Here's the entire code:
Range("A1:B1").Select
Range(Selection, Selection.End(xlDown)).Select
'create pt for trust acct
ActiveWorkbook.PivotCaches.Add(SourceType:=xlConsolidation,
SourceData:= _
Array("Sheet1!R1C1:R76C2", "Item1")).CreatePivotTable
TableDestination:= _
"'[Funds Ops Recon 06232009.xls]Sheet1'!R16C10",
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10

ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems("Sum of
Value").Position = 1 '<<<<< this line is
where it fails
ActiveWorkbook.ShowPivotTableFieldList = True
Application.CommandBars("PivotTable").Visible = False
ActiveWorkbook.ShowPivotTableFieldList = False

Thanks in advance for any tips

--
Chris Freeman
IT Project Coordinator
 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      24th Jun 2009
Hi Chris

I think the problem with your code is you are trying to move the 'Sum
of Value'. The pivot item is 'Value'. If you change the code
slightly so you move the value field, so;

With ActiveSheet.PivotTables("PivotTable1").PivotFields("Value")
.Position = 1
End With

This should work...... Hope it helps.


Take care

Marcus
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table VB code? pgarcia Microsoft Excel Programming 1 3rd Mar 2009 09:20 PM
Pivot Table Code - Simple Code Fix? J.W. Aldridge Microsoft Excel Programming 2 4th Apr 2008 02:24 PM
Code that will rerun or refresh a pivot table (after new data ispasted into the original Pivot Table's Source Range) Mike C Microsoft Excel Programming 3 15th Feb 2008 06:22 AM
Code for a Macro that allows a Pivot table to be repeatedly run (fora dynamic rows in a table, but static field names) Mike C Microsoft Excel Programming 1 11th Feb 2008 04:30 AM
VBA Code for a pivot table to open database and to reference table current page Pete Straman Straman via OfficeKB.com Microsoft Excel Programming 0 21st Feb 2005 03:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:18 AM.