Plot graph using cell adress instead of cell values

Sardo

New Member
Joined
Jul 16, 2017
Messages
6
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:

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
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top