Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|