VBA to hide chart

Tfox2791

New Member
Joined
Nov 21, 2012
Messages
32
I am using the code below in an attempt to hide the entire chart itself. For some reason it hides the chart data or something so the chart still remains visible just blank? Any suggestions?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A5").Value = "EST1" Then
Sheets("Dashboard").Shapes("MWC1").Visible = True
Sheets("Dashboard").Shapes("MWC2").Visible = False
Sheets("Dashboard").Shapes("MWC3").Visible = False
ElseIf Range("A5").Value = "EST2" Then

Sheets("Dashboard").Shapes("MWC1").Visible = True
Sheets("Dashboard").Shapes("MWC2").Visible = True
Sheets("Dashboard").Shapes("MWC3").Visible = True

Else

Sheets("Dashboard").Shapes("MWC1").Visible = True
Sheets("Dashboard").Shapes("MWC2").Visible = True
Sheets("Dashboard").Shapes("MWC3").Visible = True


End If
End Sub



Thanks!!!!!!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi,

Assuming the shape names are the chart names then all I can say is it works for me.

Have you perhaps got more charts on display than you think, maybe some without data?

Here is some code that will list out all the Charts on the Dashboard sheet:
Code:
Sub chList()
    Dim ch  As ChartObject
    For Each ch In Sheets("Dashboard").ChartObjects
        Debug.Print ch.Name
    Next
End Sub
The list will be written to the Immediate Window.
(Either select from VBE View menu of hit Ctrl + G to view.)
 
Upvote 0
Thanks for your reply Rick. I figured it out by accident. I set it up based off of a selection change when it should have been set up on a button click. Once I selected another cell in the worksheet it worked, go figure.

Anyway thanks again!
 
Upvote 0

Forum statistics

Threads
1,215,736
Messages
6,126,552
Members
449,318
Latest member
Son Raphon

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