I am trying to create charts in excel using VBA . The code is as follows :
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
Now, I want to be able to perform the actions when i=2 and i=3 on the same chart i created when i=1
However, I am not able to do so.
So can anyone help me how to give a name for the chart i created when i=1 and be able to refer to it whie i=2 and i=3??