Solved

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

Posted on 2013-05-16
3
893 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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