Hello
I have to hundreds of columns and I have to create a graph for each one of them, so I created the following macro to save me some time:
The only problem is that it used the values in the cells instead of the cell adress. I already tried to define each "ActiveCell.Offset" as an adress or define a "Range.Adress" for each range, but I keep getting code errors.
Can anyone help?
Thank you in advance
I have to hundreds of columns and I have to create a graph for each one of them, so I created the following macro to save me some time:
Code:
Sub PlotC()
'
' Macro PlotC
'
a = Range(ActiveCell.Offset(1, 0), AddressveCell.Offset(0, 0))
b = Range(ActiveCell.Offset(2, 0), ActiveCell.Offset(3, 0))
c = Range(ActiveCell.Offset(4, 0), ActiveCell.Offset(5, 0))
d = Range(ActiveCell.Offset(6, 0), ActiveCell.Offset(7, 0))
e = Range(ActiveCell.Offset(8, 0), ActiveCell.Offset(9, 0))
f = Range(ActiveCell.Offset(10, 0), ActiveCell.Offset(11, 0))
g = Range(ActiveCell.Offset(12, 0), ActiveCell.Offset(13, 0))
h = Range(ActiveCell.Offset(14, 0), ActiveCell.Offset(15, 0))
i = Range(ActiveCell.Offset(16, 0), ActiveCell.Offset(17, 0))
ActiveSheet.Shapes.AddChart2(332, xlLineMarkers).Select
Application.CutCopyMode = False
ActiveChart.FullSeriesCollection(1).Name = "Avg"
ActiveChart.FullSeriesCollection(1).Values = a
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(2).Name = "Avg + s"
ActiveChart.FullSeriesCollection(2).Values = b
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(3).Name = "Avg - s"
ActiveChart.FullSeriesCollection(3).Values = c
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(4).Name = "Avg + 2s"
ActiveChart.FullSeriesCollection(4).Values = d
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(5).Name = "Avg - 2s"
ActiveChart.FullSeriesCollection(5).Values = e
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(6).Name = "Avg + 3s"
ActiveChart.FullSeriesCollection(6).Values = f
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(7).Name = "Avg - 3s"
ActiveChart.FullSeriesCollection(7).Values = g
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(8).Name = "USL"
ActiveChart.FullSeriesCollection(8).Values = h
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(9).Name = "LSL"
ActiveChart.FullSeriesCollection(9).Values = i
End Sub
The only problem is that it used the values in the cells instead of the cell adress. I already tried to define each "ActiveCell.Offset" as an adress or define a "Range.Adress" for each range, but I keep getting code errors.
Can anyone help?
Thank you in advance