我正在尝试使用 VBA 在 excel 中创建图表。代码如下:
Sub testmacro()
Dim i As Integer
i = Sheets("Data").Range("M2").Value
Sheets("Email ID").Activate
Range("A1").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
If i = 1 Then
ActiveChart.SetSourceData Source:=Range("Data!$E$1:$F$3")
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Fill
.
.
.
End If
If i = 2 Then
End if
If i=3 Then
End If
End Sub
现在,我希望能够在 i=1 时创建的同一图表上执行 i=2 和 i=3 时的操作
但是,我无法这样做。
那么任何人都可以帮助我如何为我在 i=1 时创建的图表命名并能够在 i=2 和 i=3 时引用它吗?