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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,164
Messages
6,170,435
Members
452,326
Latest member
johnshaji

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