Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA-如何为图表系列集合选择单元格的动态范围?_Vba_Excel_Dynamic Chart Series - Fatal编程技术网

Excel VBA-如何为图表系列集合选择单元格的动态范围?

Excel VBA-如何为图表系列集合选择单元格的动态范围?,vba,excel,dynamic-chart-series,Vba,Excel,Dynamic Chart Series,我试图定义一个图表系列集合,它从一个确定的单元格到数据的末尾(向下和向右) 我使用以下代码设置轴的标签: oGrafico.Chart.SeriesCollection(nNoSerie).XValues = oPestana.Range(oPestana.Cells(46,14), oPestana.Cells(46,43)) 我尝试对数据系列使用类似的方法,将范围分配给代码,但弹出错误“应用程序定义的或对象定义的错误”: 我也试过用“oPestana.Range”代替“oPestana.C

我试图定义一个图表系列集合,它从一个确定的单元格到数据的末尾(向下和向右)

我使用以下代码设置轴的标签:

oGrafico.Chart.SeriesCollection(nNoSerie).XValues = oPestana.Range(oPestana.Cells(46,14), oPestana.Cells(46,43))
我尝试对数据系列使用类似的方法,将范围分配给代码,但弹出错误“应用程序定义的或对象定义的错误”:


我也试过用“oPestana.Range”代替“oPestana.Cells”,但我想我遗漏了一些东西。有没有办法以类似的方式设置数据系列?

这对您有用吗

oGrafico.Chart.SeriesCollection(nNoSerie).Values = oPestana.Cells(47, 14).End(xlToRight).Resize(oPestana.Range(oPestana.Cells(46, 47), oPestana.Cells(46, 47).End(xlDown)).Cells.Count - 1, 1)

您是否考虑过使用命名范围或表?
oGrafico.Chart.SeriesCollection(nNoSerie).Values = oPestana.Cells(47, 14).End(xlToRight).Resize(oPestana.Range(oPestana.Cells(46, 47), oPestana.Cells(46, 47).End(xlDown)).Cells.Count - 1, 1)