Good Afternoon
Could you please help? I have tried using a macro (see code below) I recorded to compile a Pivot Table, but the second time I ran I got the error meaaage “Runtime error ‘1004’ AddFields method of Pivot Table failed,, and when I ran debug it highlights ‘ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Fork Area"’ – which seems to stop the process when it is adding the Fork Area range (from Column N) into the Row field in the Pivot Table.
The macro was for a simple Pivot Table which was being created on the same sheet as the data in cell Q4 and was using the range Fork Area (N Column) and getting a sum total of SCR QTY (column D) – this was placed in the Data felid
Thank you in advance for your help
Regards
Jupops
Sub Macro1()
'
' Macro1 Macro
Columns("A:N").Select
Range("N1").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!C1:C14").CreatePivotTable TableDestination:="[test1.xls]Sheet1!R4C17" _
, TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Fork Area"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SCR QTY")
.Orientation = xlDataField
.Caption = "Sum of SCR QTY"
.Function = xlSum
End With
ActiveWindow.SmallScroll ToRight:=3
Columns("Q:R").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Could you please help? I have tried using a macro (see code below) I recorded to compile a Pivot Table, but the second time I ran I got the error meaaage “Runtime error ‘1004’ AddFields method of Pivot Table failed,, and when I ran debug it highlights ‘ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Fork Area"’ – which seems to stop the process when it is adding the Fork Area range (from Column N) into the Row field in the Pivot Table.
The macro was for a simple Pivot Table which was being created on the same sheet as the data in cell Q4 and was using the range Fork Area (N Column) and getting a sum total of SCR QTY (column D) – this was placed in the Data felid
Thank you in advance for your help
Regards
Jupops
Sub Macro1()
'
' Macro1 Macro
Columns("A:N").Select
Range("N1").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet1!C1:C14").CreatePivotTable TableDestination:="[test1.xls]Sheet1!R4C17" _
, TableName:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Fork Area"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SCR QTY")
.Orientation = xlDataField
.Caption = "Sum of SCR QTY"
.Function = xlSum
End With
ActiveWindow.SmallScroll ToRight:=3
Columns("Q:R").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub