I'm trying to automate the creation of graphs in Excel by means of a macro. I have lots of data (currently, columns A to AM). I want one graph in total, with multiple series.
I now have code for two series, but am wondering if it is possible to make a sort of loop that loops through the data and adds a series to the chart. I hope someone can help me in the right direction.
I currently have this:
Code
Sub AutomatedGraph()
'
'
ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Select
ActiveSheet.Shapes("Chart 2").IncrementLeft 202.5
ActiveSheet.Shapes("Chart 2").IncrementTop -163.9285826772
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).XValues = "=Data!$A$24:$A$31"
ActiveChart.FullSeriesCollection(1).Values = "=Data!$Y$24:$Y$31"
ActiveChart.FullSeriesCollection(1).Name = "=Data!$Y$23"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(2).XValues = "=Data!$A$24:$A$31"
ActiveChart.FullSeriesCollection(2).Values = "=Data!$Z$24:$Z$31"
ActiveChart.FullSeriesCollection(2).Name = "=Data!$Z$23"
End Sub
Display More