Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pivot Problems


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:=xlDatab ase, 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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Pivot Problems

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.

Philip Wagenaar wrote:
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:=xlDatab ase, 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?




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table Problems [email protected] Excel Worksheet Functions 0 December 21st 06 03:15 PM
pivot table problems CatherineC Excel Worksheet Functions 3 March 21st 06 11:08 PM
pivot table problems CatherineC Excel Worksheet Functions 0 March 21st 06 06:43 PM
Pivot table problems [email protected] Excel Discussion (Misc queries) 1 December 13th 05 02:37 AM
Pivot Table problems Randy Starkey Excel Programming 2 March 31st 05 01:50 AM


All times are GMT +1. The time now is 09:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"