Pivot Table Error
I used the Macro Recorder to create the following code to generate a Pivot
Table. When I try to run it I get the following error: "AddFeilds method of Pivot Table Class Failed". Any ideas how to make this work? Sheets("Allocation").Select Cells.Select Application.CutCopyMode = False ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _ "Allocation!C1:C6").CreatePivotTable TableDestination:= _ "'[Conversion Workbook.xls]Allocation'!R1C8", TableName:="PivotTable1", _ DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("Social Security Number", "Source Name"), ColumnFields:="Fund Name" ActiveSheet.PivotTables("PivotTable1").PivotFields ("Cash").Orientation = _ xlDataField Range("H4").Select ActiveSheet.PivotTables("PivotTable1").PivotFields ("Social Security Number"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) Range("J5").Select ActiveSheet.PivotTables("PivotTable1").PivotFields ("Count of Cash").Function = _ xlSum End Sub |
Pivot Table Error
The SourceData is "Allocation!C1:C6" which doesn't look right for a
pivot table source. If you change that to the correct range, perhaps the macro will run correctly. ToddEZ wrote: I used the Macro Recorder to create the following code to generate a Pivot Table. When I try to run it I get the following error: "AddFeilds method of Pivot Table Class Failed". Any ideas how to make this work? Sheets("Allocation").Select Cells.Select Application.CutCopyMode = False ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _ "Allocation!C1:C6").CreatePivotTable TableDestination:= _ "'[Conversion Workbook.xls]Allocation'!R1C8", TableName:="PivotTable1", _ DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("Social Security Number", "Source Name"), ColumnFields:="Fund Name" ActiveSheet.PivotTables("PivotTable1").PivotFields ("Cash").Orientation = _ xlDataField Range("H4").Select ActiveSheet.PivotTables("PivotTable1").PivotFields ("Social Security Number"). _ Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _ False, False) Range("J5").Select ActiveSheet.PivotTables("PivotTable1").PivotFields ("Count of Cash").Function = _ xlSum End Sub -- Debra Dalgleish Contextures http://www.contextures.com/tiptech.html |
All times are GMT +1. The time now is 09:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com