以下是引用chenjun在2004-11-10 12:24:00的发言:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Column = 2 And Target <> "" Then
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.PivotLayout.PivotFields("大区").CurrentPage = Target.Offset(0, -1).Value
ActiveChart.PivotLayout.PivotFields("分公司").CurrentPage = Target.Value
End If
Target.Select
Application.ScreenUpdating = True
End Sub
其中的ActiveSheet.ChartObjects("图表 1").Activate可以改为ActiveSheet.ChartObjects(1).Activate,这里的1可以是本工作表的图表的序号。
原来缺了一句:“ActiveChart.PivotLayout.PivotFields("大区").CurrentPage = ”!!!
Chenjun多谢! |