Hi,
I am trying to insert a toggle or command button that will show and hide a chart that is on a different sheet in the same workbook.
I have used the below command button to achieve this with a chart on the same worksheet.
Private Sub CommandButton1_Click()
If Me.ChartObjects("Chart 2").Visible Then
Me.ChartObjects("Chart 2").Visible = False
CommandButton1.Caption = "Show Chart"
Else
Me.ChartObjects("Chart 2").Visible = True
CommandButton1.Caption = "Hide Chart"
End If
End Sub
I have tried other options to achieve this for a chart that is on another sheet but it is not working.
Please help.
Thanks.
I am trying to insert a toggle or command button that will show and hide a chart that is on a different sheet in the same workbook.
I have used the below command button to achieve this with a chart on the same worksheet.
Private Sub CommandButton1_Click()
If Me.ChartObjects("Chart 2").Visible Then
Me.ChartObjects("Chart 2").Visible = False
CommandButton1.Caption = "Show Chart"
Else
Me.ChartObjects("Chart 2").Visible = True
CommandButton1.Caption = "Hide Chart"
End If
End Sub
I have tried other options to achieve this for a chart that is on another sheet but it is not working.
Please help.
Thanks.