以下是引用yanjie在2007-11-11 23:11:50的发言:用VBA做的,不知道是否正确,请验证! 太厉害!太谢谢了! 但我看不懂[em04] Private Sub Worksheet_Activate() Dim pv As PivotTable, rng As Range Set pv = Sheet1.[b3].PivotTable pv.RefreshTable pv.ManualUpdate = False On Error Resume Next pv.DataPivotField.Orientation = xlHidden For Each rng In Worksheets("明细表").Range("c1", Sheets("明细表").[iv1].End(xlToLeft)) pv.AddDataField pv.PivotFields(rng.Value), " " & rng.Value, xlSum Next rng pv.ManualUpdate = True End Sub Sub Macro1() ' ' Macro1 Macro ' Macro recorded 2007-11-11 by Lenovo User ' ' Range("F9").Select Selection.ShowDetail = True Sheets("汇总结果").Select ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _ ).PivotFields("07年3季"), "Sum of 07年3季", xlSum Range("H8").Select ActiveWindow.SmallScroll Down:=-15 End Sub Sub Macro2() ' ' Macro2 Macro ' Macro recorded 2007-11-11 by Lenovo User ' ' Range("H4").Select ActiveSheet.PivotTables("数据透视表1").PivotFields(" 07年2季").Orientation = xlHidden Range("F8").Select End Sub Sub Macro3() ' ' Macro3 Macro ' Macro recorded 2007-11-11 by Lenovo User ' ' Range("C3").Select ActiveSheet.PivotTables("数据透视表1").DataPivotField.Orientation = xlHidden End Sub
|