VBA:如何在图表中创build一个具有多于1个X值的系列

我正在尝试使用VBA创build一个具有超过1个X值的新系列。

创build一个只有一个X值的系列是没有问题的,但是它不能工作。 谁能帮忙?

作品:

.XValues = "=" & Dataws.Cells(CurrentRow, 3).Address(False, False, xlA1, xlExternal) 

不起作用(运行时错误1004):

 .XValues = "=" & Dataws.Cells(CurrentRow, 3) & Dataws.Cells(CurrentRow, 14) & Dataws.Cells(CurrentRow, 15) & Dataws.Cells(CurrentRow, 16) & Dataws.Cells(CurrentRow, 17) & Dataws.Cells(CurrentRow, 18) & Dataws.Cells(CurrentRow, 19) & Dataws.Cells(CurrentRow, 20) & Dataws.Cells(CurrentRow, 21) & Dataws.Cells(CurrentRow, 22).Address(False, False, xlA1, xlExternal) 

谢谢!

XValues的地址需要用逗号分隔。

结果应该如下所示: =[Map1]Sheet1!C1,[Map1]Sheet1!N1:V1


所以你需要连接两个地址与& "," &

 .XValues = "=" & dataws.Cells(CurrentRow, 3).Address(False, False, xlA1, xlExternal) & "," & _ dataws.Range(dataws.Cells(CurrentRow, 14), dataws.Cells(CurrentRow, 22)).Address(False, False, xlA1, xlExternal) 

请注意,连续单元格可以组合到一个范围地址,如:

 dataws.Range(dataws.Cells(CurrentRow, 14), dataws.Cells(CurrentRow, 22)) 

这意味着单元格14到单元格22.所以你不需要单独添加它们。