单dynamicgraphics代码

在excel中,我有4组属性,这些属性具有水平的租赁数据,相应的租赁数据月份在顶部水平。 属性被列出垂直。

June,'15 July,'15 Set 1 prop 1 $2,588.00 $2,588.00 prop 2 $1,835.00 $1,829.00 Set 2 prop 3 $2,647.00 $2,707.00 prop 4 $2,501.00 $2,526.00 

我想为单个图创build一个VBA代码,select属性Set 1或Set 2中的数据添加到图中。 这取决于Excel中另一个单元格(下拉列表)的更改:

 Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range ' The variable KeyCells contains the cells that will cause an alert when they are changed. Set KeyCells = Range("D5") If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then 'This is where I would place the graph code End If End Sub 

什么是实现这个任务的代码 – build立一个dynamic变化的graphics?

 Private Sub Worksheet_Change(ByVal Target As Range) Dim KeyCells As Range ' The variable KeyCells contains the cells that will cause an alert when they are changed. Set KeyCells = Range("D5") If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then If Range("D5") = "Tremont" Then Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).XValues = Range(X_axis_values) Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).Name = "Tremont" Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).Values = Range(Y_axis_values) 'If a bar graph, with Selection.Format.Fill .Visible = msoTrue .ForeColor.RGB= RGB(0,0,0) .Transparency = 0 .Solid End With ElseIf Range("D5") = "Saybrook Pointe" Then Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).XValues = Range(X_axis_values) Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).Name = "Saybrook Pointe" Activesheet.Chartobjects("Single_Dynamic_Chart").FullSeriesCollection(1).Values = Range(Y_axis_values) 'If a bar graph, with Selection.Format.Fill .Visible = msoTrue .ForeColor.RGB= RGB(0,0,0) .Transparency = 0 .Solid End With ElseIf Range("D5") = "21 Fitzsimons" Then 'Similarly like above cases, define the X-axis,the series name and the values. ElseIf Range("D5") = "Mezzo" Then 'Similarly like above cases, define the X-axis,the series name and the values. End If End If End Sub