"Macroa" 宏是选定的一个范围 【Sub Macroa() ' ' Macroa Macro ' 宏由 User 录制,时间: 2008-2-17 ' ' 快捷键: Ctrl+w ' Columns("A:A").Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.FormulaR1C1 = "=R[-1]C" Selection.End(xlDown).Select ActiveWindow.SmallScroll Down:=3 Selection.EntireRow.Delete Shift:=xlUp ActiveWindow.SmallScroll Down:=-18 ActiveWindow.ScrollRow = 1335 ActiveWindow.ScrollRow = 1314 ActiveWindow.ScrollRow = 1295 ActiveWindow.ScrollRow = 1243 ActiveWindow.ScrollRow = 1132 ActiveWindow.ScrollRow = 940 ActiveWindow.ScrollRow = 661 ActiveWindow.ScrollRow = 396 ActiveWindow.ScrollRow = 188 ActiveWindow.ScrollRow = 12 ActiveWindow.ScrollRow = 1 ActiveWindow.ScrollRow = 1340 ActiveWindow.ScrollRow = 1 Range("A1").Select Selection.CurrentRegion.Select End Sub 】 要求在 "Macroa" 选定的范围生成数据透视表 Sub Macro1() ' ' Macro1 Macro ' 宏由 User 录制,时间: 2008-2-18 ' ' 快捷键: Ctrl+r ' Application.Run "Macroa" ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "销售出库序时簿!R1C1:R72C83").CreatePivotTable TableDestination:="", TableName:= _ "数据透视表1", DefaultVersion:=xlPivotTableVersion10 ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1) ActiveSheet.Cells(3, 1).Select With ActiveSheet.PivotTables("数据透视表1").PivotFields("产品名称") .Orientation = xlRowField .Position = 1 End With With ActiveSheet.PivotTables("数据透视表1").PivotFields("产品长代码") .Orientation = xlRowField .Position = 2 End With Range("B6").Select ActiveSheet.PivotTables("数据透视表1").PivotFields("产品名称").Subtotals = Array(False, _ False, False, False, False, False, False, False, False, False, False, False) ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _ ).PivotFields("实发数量"), "求和项:实发数量", xlSum ActiveWorkbook.ShowPivotTableFieldList = False End Sub
[此贴子已经被作者于2008-2-18 12:12:35编辑过] |