Dynamic Visibility of Charts Through Checkbox Selection

  • Thread starter Thread starter R Tanner
  • Start date Start date
R

R Tanner

Hi,

I'm trying to base the visibility of a chart off of whether a specific
checkbox is selected or not. What should I be doing differently in my
code?

Sub ChangeChartVisibility()
Dim tc As Object, cb As Object
Set tc = Application.ActiveSheet.ChartObjects("Chart 3")
Set cb = Application.ActiveSheet.MsForms.CheckBox("VolumeIndicators")

If cb.Enabled = True Then
tc.Visible = True
Else
If cb.Enabled = False Then
tc.Visible = False
End If


End Sub
 
Hi,

Maybe you want to use the Value rather than whether the control is enabled
or not.

Sub ChangeChartVisibility()
Dim tc As Object, cb As Object
Set tc = Application.ActiveSheet.ChartObjects("Chart 3")
Set cb = Application.ActiveSheet.MsForms.CheckBox("VolumeIndicators")

tc.Visible = cb.value

End sub

Cheers
Andy
 
Back
Top