选择图表的数据范围

时间:2015-09-17 09:28:00

标签: excel vba excel-vba

目前我遇到了一些代码问题,我试图从我创建的宏中选择图表的源数据:

  With ActiveWorkbook.Sheets("Info").ChartObjects("Speed").Activate

    ActiveChart.SetSourceData Source:=Sheets("Log").Range("A5").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range("C5").Activate
    Range(Selection, Selection.End(xlDown)).Select
End With

我正在返回“无法获取Range类的Select属性”。

我需要能够从“A5”开始获取源数据并向下移动到最后一段数据(会有所不同),这与“C5”相同。

1 个答案:

答案 0 :(得分:0)

你尝试过这样的事吗?

With ThisWorkbook.Sheets("Log")
     ThisWorkbook.Sheets("Info").ChartObjects("Speed").Chart _
         .SetSourceData Source:=ThisWorkbook.Sheets("Log").Range(.Cells(5,1), _
         .Cells(.Cells(Rows.Count, 3).End(xlup).Row, 3))
End With
相关问题