?
Solved

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

Posted on 2013-05-16
3
Medium Priority
?
973 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 1000 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 1000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 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