• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

vba: hide chart

dan_l

Active Member
This may be simple. Here's the set up:

I've 4 dynamic charts in a 'dashboard' kind of layout. The sources for the charts change based on vba. Each chart has it's own "display" flag to deal with a bunch of conditions where I won't want ot display the chart.

So, no data to display, some values I want to filter out, etc, the flag will throw 0.

During the print routine, I want to make excel hide the entire chart when the flag is 0. So whereas the output sheet will have 4 charts, if one of the flag is 0, I'll see only one.

I don't think there's a visible property for a chart. So I'm not sure what approach to take.
 
You can use the Shapes collection to hide the chart. So for example
Code:
If Flag1=0 Then
Shapes("NameOfChart1").Visible = False
Else
Shapes("NameOfChart1").Visible = False
End if

Having said that

Code:
activesheet.ChartObjects("NameOfChart").visible=false
works perfectly fine
 
Weird.

Not that it matters, but I can't get it to work with activesheet. Rather, I actually have to specify the sheet. For this project it will be fine because I'll have the sheets named pretty clearly.

Thanks.
 
Back
Top