![]() |
Runtime Error '1004' - AddFields method of PivotTable class failed
Hi,
I can create a pivottable fine but when I record this to a macro and try to run the macro I get an error on this line: ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:=Array("STAGE", _ "SUB STAGE", "BUSINESS DESC", "Data"), ColumnFields:="EXPIRED" Does anyone know what the solution to this is? (Note: I did a search on this topic and found nothing) Full macro code below: Sub Create_PivotTable() ' ' Create_PivotTable Macro ' Macro recorded 21/05/2004 by MikeC ' ' Sheets("TransferInData").Select ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _ "TransferInData!C1:C8").CreatePivotTable TableDestination:="", TableName:= _ "PivotTable3", DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1) ActiveSheet.Cells(3, 1).Select ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:=Array("STAGE", _ "SUB STAGE", "BUSINESS DESC", "Data"), ColumnFields:="EXPIRED" With ActiveSheet.PivotTables("PivotTable3").PivotFields ("BUSINESS DESC") .Orientation = xlDataField .Position = 1 End With With ActiveSheet.PivotTables("PivotTable3").PivotFields ("PROCESSED") .Orientation = xlDataField .Position = 2 End With ActiveSheet.PivotTables("PivotTable3").PivotFields ("BUSINESS DESC"). _ Orientation = xlDataField ActiveWorkbook.ShowPivotTableFieldList = True ActiveWorkbook.ShowPivotTableFieldList = False ActiveWindow.SmallScroll Down:=12 End Sub Regards, MikeC |
All times are GMT +1. The time now is 07:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com