Solved

Show/hide a pie chart in Excel if the a cell equals 0

Posted on 2013-05-16
3
911 Views
Last Modified: 2013-05-19
Hi Experts

I have a chart (Chart16) on a worksheet tab (Devices) which I would like to completely hide (including chart titles, legend, values etc. ) if the value in Cell N17 is 0 and display if it's anything else.

Is this possible?

Thanks
darls15
0
Comment
Question by:darls15
3 Comments
 

Accepted Solution

by:
Redheadache earned 250 total points
ID: 39173828
You can use VBA for this.  It would be something like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("N17").Value = 0 Then
          Sheets("Devices").ChartObjects("Chart16").Visible = False
ElseIf Range("N17").Value <> 0 Then
           
        Sheets("Devices").ChartObjects("Chart16").Visible = True            
     End If
End Sub
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 250 total points
ID: 39173830
The code to show or hide Chart16 can be as simple as this:
Sub ChartViewer()
With Worksheets("Devices")
    .ChartObjects("Chart16").Visible = (.[N17] <> 0)
End With
End Sub

Open in new window


If you would like the chart visibility to occur automatically, then you could integrate the above code with a Worksheet_Change event macro. The details will depend on whether the value of cell N17 is set by formula or user input.
0
 

Author Closing Comment

by:darls15
ID: 39179614
Both solutions work perfectly, thank you both for your help :)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question