Excel VBA宏:将源数据设置为单独的列

时间:2017-11-16 16:43:27

标签: excel vba excel-vba charts excel-formula

我正在尝试动态地为多个单独的列更新VBA中图表的数据范围源。详情如下:

Sub ChartValue2()

Dim rg As Range
Dim i As Integer

i = WorksheetFunction.CountA(Range("A:A"))
Set rg = Range("$A$1", Range("$A$1").End(xlToRight).End(xlDown))

ActiveChart.ChartArea.Select

ActiveChart.SetSourceData Source:=Range("rg.Columns(1), rg.Columns(3)")

End Sub

AS in the picture my code will select the whole range from column 1 to column 3. Instead what i want to achieve is to source column 1 & 3 separately. Thanks in advance.

正如您在图像中看到的,我的代码正在从第1列到第3列中选择整个范围,但我想要的是选择第1列和第1列。 3另外。

我该怎么做?

0 个答案:

没有答案