Hide / Unhide Chart when selectring Yes, No from a drop box

bradygra

New Member
Joined
Apr 16, 2015
Messages
1
Hi all,

I am trying to hide a chart when I select No from a drop box and then reappear again when I select Yes from the same box.
I have looked online and found some coding for VBA but I have no idea what I am doing with VBA.
I have managed to hide the cells that the chart gets its data from using conditional formatting by just turning the cells white to hide the data, when I select No, but I can't seem to figure out how to make the Chart disappear.
If it helps I've called the Chart - Chart 2.

Another thing I'm wondering is there a away to set the default printer to PDFCreater instead of HP Inkjet.............


As I say I'm completely useless with VBA.
I appreciate that this question will be asked about 100 times.


Many Thanks

bradygra
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You want to actually "hide" the chart. Not the cells the chart hovers over.

Code:
ActiveSheet.Shapes("Chart 2").Visible = [COLOR=#0000ff]True [/COLOR]
[COLOR=#008000]'or[/COLOR] 
ActiveSheet.Shapes("Chart 2").Visible = [COLOR=#0000ff]False[/COLOR]

So whatever cell you have the "Yes" / "No" in it would go like this:


Code:
[COLOR=#0000ff]Private Sub [/COLOR]Worksheet_Change([COLOR=#0000ff]ByVal[/COLOR] Target[COLOR=#0000ff] As[/COLOR] Range)
[COLOR=#008000]'Put this in the worksheet module[/COLOR]

[COLOR=#0000ff]If [/COLOR]Range("A1").Value = "Yes" [COLOR=#0000ff]Then[/COLOR]
ActiveSheet.Shapes("Chart 2").Visible = [COLOR=#0000ff]True[/COLOR] 
[COLOR=#0000ff]Else[/COLOR]
ActiveSheet.Shapes("Chart 2").Visible = [COLOR=#0000ff]False[/COLOR]
[COLOR=#0000ff]End If[/COLOR]

[COLOR=#0000ff]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,262
Messages
6,171,080
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top