更新图表适用于除最后一个之外的所有图

时间:2015-12-07 20:25:25

标签: vba

我无法弄清楚为什么10个图表中的前9个将使用以下代码更新,但最后一个(图11)只会捕获最后一列数据而不是全部数据。我使用的代码如下:

Sub UpdateCharts(rw As Long)

' Updates the charts based on the data that was updated
' in the "Chart Data" tab for given week.

    Sheets("Metrics").Select

    ActiveSheet.ChartObjects("Chart 8").Activate 'Total Open
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("A1:E" & rw)
    ActiveSheet.ChartObjects("Chart 1").Activate 'Open & Assigned
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("H2:L" & rw)
    ActiveSheet.ChartObjects("Chart 2").Activate 'Open & Un-Assigned
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("N2:R" & rw)
    ActiveSheet.ChartObjects("Chart 3").Activate '7 Day Ratio
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("T2:X" & rw)
    ActiveSheet.ChartObjects("Chart 7").Activate 'Open & In Progress
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("AV2:AZ" & rw)
    ActiveSheet.ChartObjects("Chart 6").Activate 'Open & Not Started
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("AO2:AS" & rw)
    ActiveSheet.ChartObjects("Chart 5").Activate 'Completed On-Time
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("AH2:AL" & rw)
    ActiveSheet.ChartObjects("Chart 4").Activate '30 Day Ratio
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("AA2:AE" & rw)
    ActiveSheet.ChartObjects("Chart 11").Activate 'Completed Per Coordinator
    ActiveChart.SetSourceData Source:=Sheets("Chart Data").Range("BC2:BN" & rw)
End Sub

0 个答案:

没有答案