Automatically add series to graph

bujaman

Board Regular
Joined
Apr 2, 2009
Messages
56
I want to add series to a graph based on whether a checkbox next to the series is checked. There are 11 possible graphs to add, and the data is found in range W148:AC158. Here is what I have so far:


Code:
ActiveSheet.ChartObjects("Chart 6").Activate
Dim n


  With ActiveChart
       n = 8
        For i = .SeriesCollection.Count To 11 Step 1
            If Sheets("Inputs").OLEObjects("CheckBox" & i).Object.Value = True Then
            .SeriesCollection.NewSeries
            .SeriesCollection(i).Name = Worksheets("Inputs").Range("W14" & n).Text
            .SeriesCollection(i).XValues = Worksheets("Inputs").Range("AB14" & n & ":AC14" & n).Value
            .SeriesCollection(i).Values = Worksheets("Inputs").Range("Z14" & n & ":$AA$14" & n).Value
        n = n + 1
        Next i
        
    End With

I am not having much luck so far, any ideas? Thanks.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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