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)