Solved

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

Posted on 2013-05-16
3
858 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
Comment Utility
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 80

Assisted Solution

by:byundt
byundt earned 250 total points
Comment Utility
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
Comment Utility
Both solutions work perfectly, thank you both for your help :)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now