Solved

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

Posted on 2013-05-16
3
933 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Create Professional Looking Email Signatures

Create "Professional HTML Email Signatures" with ease.
7 Day Money Back Guarantee if not 100% Satisfied.
Affordable - Try it out for 7 Days Totally Risk Free.
Installers provided for over 45 Email clients.
Both Windows & MAC Supported.
Highly Recommended!

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

732 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