LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Creating Pivot Tables with macro Problem

Hi All,

I create files from results of a query in an application...so the data range
changes constantly based on the items in the query...anyway...to hopefully do
all the formulas and pivot table creation in a macro that can be used with
each new query.

All works fine except...the 1st pivot table created will not include the row
fields...all other pivots in the same macro are created just fine..even using
some of the same row fields.

Below is the code I am using to start...the array for RowFields are the
hang-up. The fields are correct as entered...including the few with an
underscore in the titles.

I am totally stumped as what to try and any help would be greatly appreciated!

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Current Oblig'!R1C1:R5932C36").CreatePivotTable
TableDestination:="", TableName:= _
"PivotTable1"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("BU
Code", _
"Vendor Alpha", "VENDOR_NAME", "FY", "BPO_NUMBER")
With
ActiveSheet.PivotTables("PivotTable1").PivotFields ("OBLIGATION_AMOUNT")
.Orientation = xlDataField
.Caption = "Sum of OBLIGATION_AMOUNT"
.Function = xlSum
End With

Tis is the portion of the 2nd pivot table created in the macro and works
perfect...including the rows added to the pivot for and array.

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Current Oblig'!R1C1:R5932C36").CreatePivotTable
TableDestination:=Range _
("H3"), TableName:="PivotTable2"
ActiveSheet.PivotTables("PivotTable2").SmallGrid = False
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("BU
Code", _
"FY", "Rec'd or Not")
With
ActiveSheet.PivotTables("PivotTable2").PivotFields ("OBLIGATION_AMOUNT")
.Orientation = xlDataField
.Caption = "Sum of OBLIGATION_AMOUNT"
.Function = xlSum
End With
--
Linda

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Pivot Tables with Macros Problem Linda Excel Programming 1 November 2nd 05 05:36 PM
Problem with a recorded macro to create two pivot tables from same data rjamison Excel Programming 0 June 14th 05 12:14 AM
Problem with a recorded macro to create two pivot tables from same data Pete Straman via OfficeKB.com[_2_] Excel Programming 1 April 20th 05 05:28 PM
Creating Pivot Tables inside a Macro farrell77 Excel Programming 4 February 18th 05 09:54 PM
problem with macro for pivot tables Hans Excel Programming 0 July 8th 04 01:50 PM


All times are GMT +1. The time now is 09:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"