Macro to enable/disable chart series

lazerboi64

New Member
Joined
Feb 4, 2019
Messages
8
Greetings:

Running Excel 2013. I have created an x-y scatter chart with a dozen-plus series to show time evolution of my data. I can right-click on the chart, select "Select Data" and manually check and uncheck the appropriate series. However, it's time consuming to go through the repetition when you're trying to see small changes. I would like to have macros linked to check boxes in the sheet to directly enable/disable the appropriate series. I've tried to do this via the macro recorder, but it doesn't record anything after right-clicking on the chart. All I get is the following:

Sub Select_dataset()
'
' Select_dataset Macro
'

'
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.PlotArea.Select
End Sub

Sub Deselect_dataset()
'
' Deselect_dataset Macro
'

'
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.PlotArea.Select
End Sub

Any help would be greatly appreciated!! Thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You can use the IsFiltered property of the Series object to hide a series. For example, to hide Series 2...

Code:
ActiveSheet.ChartObjects("Chart 3").Chart.FullSeriesCollection(2).IsFiltered = True

or

Code:
ActiveChart.FullSeriesCollection(2).IsFiltered = True

And, of course, to unhide a series, set the IsFiltered property to False.

Hope this helps!
 
Upvote 1
Solution
Just tried the abbreviated version and it works like a charm. Now I just need to add some logic to toggle the filtered state so that it follows the check box. Thanks once again!
 
Upvote 0
I have tried and learned that you also can refer to the series by its name. Example:

VBA Code:
ActiveSheet.ChartObjects("Chart 3").Chart.FullSeriesCollection("Sales").IsFiltered = True
 
Upvote 0
I have tried and learned that you also can refer to the series by its name. Example:

VBA Code:
ActiveSheet.ChartObjects("Chart 3").Chart.FullSeriesCollection("Sales").IsFiltered = True
I believe I do that. In my case they're "Chart_Purple", "Chart_Yellow", etc.
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,697
Members
449,117
Latest member
Aaagu

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