Pivot Problems

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?
 
D

Debra Dalgleish

Your SourceData range is Output!C1:C45, which would only include one
field. When it tries to add fields to the pivot table, the fields don't
exist in the source data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pivot table 2
create pivot table in VBA 4
Pivottable References 1
Pivot Table Error 1
PivotTable Macro not working 2
Named argument not found 1
PLEASE HELP** Pivot table auto updating 1
Format Pivot total rows 2

Top