G
Guest
I have created Macro's in Excel and for some reason some Pivot ones do not
work anymore. Even if I record the macro again, I still get the same error:
Run-time error '1004':
AddFields method of PivotTable class failed
The following code was produced when recording the macro:
Pivot Macro
' Macro recorded 7-9-2005 by Sigrit Janssen
'
'
Cells.Select
Range("AA1").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Output!C1:C45").CreatePivotTable TableDestination:="", TableName:=
_
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Actual
Start", _
ColumnFields:="Assigned To"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Act. Dur.
Hours")
.Orientation = xlDataField
.Caption = "Sum of Act. Dur. Hours"
.Function = xlSum
End With
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False
Cells.Select
Cells.EntireColumn.AutoFit
Range("B8").Select
End Sub
How can I change this code in such a way that it will work? (if I know it
for this one, I will know it for all, I think)
Why do these macro's not work anymore, even if I record the macro again?
work anymore. Even if I record the macro again, I still get the same error:
Run-time error '1004':
AddFields method of PivotTable class failed
The following code was produced when recording the macro:
Pivot Macro
' Macro recorded 7-9-2005 by Sigrit Janssen
'
'
Cells.Select
Range("AA1").Activate
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Output!C1:C45").CreatePivotTable TableDestination:="", TableName:=
_
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Actual
Start", _
ColumnFields:="Assigned To"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Act. Dur.
Hours")
.Orientation = xlDataField
.Caption = "Sum of Act. Dur. Hours"
.Function = xlSum
End With
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False
Cells.Select
Cells.EntireColumn.AutoFit
Range("B8").Select
End Sub
How can I change this code in such a way that it will work? (if I know it
for this one, I will know it for all, I think)
Why do these macro's not work anymore, even if I record the macro again?