创建图表时的Excel变量范围 [英] Excel Variable Ranges while creating a chart

查看:205
本文介绍了创建图表时的Excel变量范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我需要能够使用这种方法选择最后一行来创建图表。

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



需要 A10 的范围才能选择A列中的最后一行。

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

推荐答案

这是你想要的吗?

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

这篇关于创建图表时的Excel变量范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆