Excel Variable Ranges while creating a chart

落花浮王杯 提交于 2019-12-21 19:53:27

问题


So basically I need to be able to select the last row to create a chart using this method.

Sub createchart2()
    lastA = Range("A1").End(xlDown).Row
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=Range("Main!$A$3:$A$10")
End Sub

I need the range for A10 to be able to select the last row in the A column.


回答1:


Is this what you are trying?

Sub createchart2()
    Dim lastA As Long

    lastA = Range("A" & Rows.Count).End(xlUp).Row

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLine

    ActiveChart.SetSourceData Source:=Range("Main!$A$3:$A$" & lastA)
End Sub


来源:https://stackoverflow.com/questions/10792732/excel-variable-ranges-while-creating-a-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!