Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default pivot table error 1004

I have a macro that loops throug a series of business area data sheets,
producing a pivot table for each business area. The pivot table is sorted by
the top ten customers.

The program stops on the third business area (even if I step through and
manually reset the order of busniess area, so its not stopping on a specific
business area).

It hangs up on this statement, giving a run-time error 1004
.AutoSort xlAscending, "Sum of Total"
Which is part of this 'with' group
With
ActiveSheet.PivotTables(categorytablename).PivotFi elds("TDO_Cust_Short")
.AutoSort xlAscending, "Sum of Total"
.AutoShow xlAutomatic, xlTop, 10, "Sum of Total"
End With

By stepping through the program, I have noticed that for the first two pivot
tables it prints the "Sum of Total" in the last row prior to selecting the
top 10.
Before I get the error 1004, it begins the last row with "Count of Total".

---- ---- MY QUESTION ENDS HERE --- ---
--- ---- For reference --- ----
---- ----- The Entire Pivot Table Call Is Given --- ----
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
myrng.Address(external:=True)).CreatePivotTable
TableDestination:="", tablename:= _
categorytablename, DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables(categorytablename).AddFiel ds RowFields:="Data", _
ColumnFields:="TDO_Cust_Short"
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY01")
.Orientation = xlDataField
.Caption = "Sum of FY01"
.Position = 1
.Function = xlSum
End With
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY02")
.Orientation = xlDataField
.Caption = "Sum of FY02"
.Position = 2
.Function = xlSum
End With
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY03")
.Orientation = xlDataField
.Caption = "Sum of FY03"
.Position = 3
.Function = xlSum
End With
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY04")
.Orientation = xlDataField
.Caption = "Sum of FY04"
.Position = 4
.Function = xlSum
End With
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY05")
.Orientation = xlDataField
.Caption = "Sum of FY05"
.Position = 5
.Function = xlSum
End With
With ActiveSheet.PivotTables(categorytablename).PivotFi elds("FY06")
.Orientation = xlDataField
.Position = 6
.Function = xlSum 'Added this, seems to be an intermittent
problem
End With

ActiveSheet.PivotTables(categorytablename).PivotFi elds("Total").Orientation =
_
xlDataField
With
ActiveSheet.PivotTables(categorytablename).PivotFi elds("TDO_Cust_Short")
.AutoSort xlAscending, "Sum of Total"
.AutoShow xlAutomatic, xlTop, 10, "Sum of Total"
End With

--
Richard
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
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Pivot Table Run Time Error 1004 Dale Excel Programming 0 May 3rd 06 04:46 PM
pivot table Commandtext causes runtime error 1004 in excel 2000 Therezee Excel Programming 0 April 12th 06 04:39 AM
Pivot Table Error 1004 Terri[_5_] Excel Programming 1 May 26th 05 10:39 AM


All times are GMT +1. The time now is 10:29 PM.

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

About Us

"It's about Microsoft Excel"