0

我已经录制了这个宏。它用于插入图表。如何创建图表形状并将其签名到变量以供以后参考?我想将变量传递给范围。我只想更改(52)号。所以如果变量是row我如何在下面的代码中使用它。我试过这个

("'Simpson'!$K$3:$L$row") 

但它不起作用

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Simpson'!$K$3:$L$52")
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.ChartTitle.Select
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.ChartTitle.Text = "integrated function chart"
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleHorizontal)
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "x values"
ActiveSheet.ChartObjects("Chart 5""""").Activate
'How can I delete the legend in one. combining the next two
ActiveChart.Legend.Select
Selection.Delete
4

1 回答 1

0

我试过了,它 ("'Simpson'!$K$3:$L$row") 不起作用

试试这个

Dim LRow as Long

LRow = 52 '<~~ Change this as required.

ActiveChart.SetSourceData Source:=Range("'Simpson'!$K$3:$L$" & LRow)
于 2012-05-17T09:05:49.250 回答