各位老师: 我录制了一段制作数据透视表宏 (指定将数据透视表放在工作表名(进度表), 但测试不能运行, 请高手指点,到底应如何调试. 不胜感激之至! 谢谢 Private Sub CommandButton1_Click() Range("F6").Select ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "生产明细!R1C1:R10000C13").CreatePivotTable TableDestination:= _ "[产能分析.xls]进度表!R3C1", TableName:="数据透视表1", DefaultVersion:= _ xlPivotTableVersion10 ActiveSheet.PivotTables("数据透视表1").AddFields RowFields:=Array("批号", "工序", "数据") With ActiveSheet.PivotTables("数据透视表1").PivotFields("FZ_SL") .Orientation = xlDataField .Caption = "发出" .Position = 1 .Function = xlSum End With With ActiveSheet.PivotTables("数据透视表1").PivotFields("JH_SL") .Orientation = xlDataField .Caption = "收回" .Position = 2 .Function = xlSum End With With ActiveSheet.PivotTables("数据透视表1").PivotFields("欠数") .Orientation = xlDataField .Caption = "欠收" .Function = xlSum End With ActiveWorkbook.ShowPivotTableFieldList = False Range("C3").Select With ActiveSheet.PivotTables("数据透视表1").DataPivotField .Orientation = xlColumnField .Position = 1 End With Columns("C:E").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With End Sub
TwDWGvCQ.rar
(74.06 KB, 下载次数: 101)
|