If cell B1 = "Day1" , show chart

R

rachitm

Is there is a function that I could use , where if a cell is equal to
Day1, it would show me an already created chart and if B1 is not "Day1"
hide that chart?

Any help is appreciated!
 
S

ShaneDevenshire

Hi,

With Debra Dalgleish method, which is one of the suggestions which I
mentioned in my first email, does not really hide the chart. It still exists
as an object on the screen. So it can still be selected, deleted or moved.
And as done in the example, it can still be seen.

The sample provide by François L, which was my other suggestion, fails not
because the idea is incorrect, but simply because the chart name is "Chart 1"
not "Graphique 1".

You can use the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
If [PickList] = "Day1" Then
ChartObjects("Chart 1").Visible = False
Else
ChartObjects("Chart 1").Visible = True
End If
End Sub

Here PickList is the range name of the cell where you enter your Day value.
You can use a Data, Validation drop down list or you can just type the day
into the cell. The Data Validation method is safer because if you type Day 1
it will not work because the spelling doesn't match Day1.

Very interesting that my two suggestions both generated a new web page on
the internet showing my solutions, both with files dated 1/21/2007!
 
D

Debra Dalgleish

Francis created a file from your idea, even though you hadn't posted it
yet? And since you had posted "you could do it with a formula", you
assume my solution was based on your suggestion? Interesting.
Hi,

With Debra Dalgleish method, which is one of the suggestions which I
mentioned in my first email, does not really hide the chart. It still exists
as an object on the screen. So it can still be selected, deleted or moved.
And as done in the example, it can still be seen.

The sample provide by François L, which was my other suggestion, fails not
because the idea is incorrect, but simply because the chart name is "Chart 1"
not "Graphique 1".

You can use the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
If [PickList] = "Day1" Then
ChartObjects("Chart 1").Visible = False
Else
ChartObjects("Chart 1").Visible = True
End If
End Sub

Here PickList is the range name of the cell where you enter your Day value.
You can use a Data, Validation drop down list or you can just type the day
into the cell. The Data Validation method is safer because if you type Day 1
it will not work because the spelling doesn't match Day1.

Very interesting that my two suggestions both generated a new web page on
the internet showing my solutions, both with files dated 1/21/2007!
 
F

Francois L

ShaneDevenshire a écrit :
The sample provide by François L, which was my other suggestion, fails not
because the idea is incorrect, but simply because the chart name is "Chart 1"
not "Graphique 1".

You can use the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
If [PickList] = "Day1" Then
ChartObjects("Chart 1").Visible = False
Else
ChartObjects("Chart 1").Visible = True
End If
End Sub
(...)
Very interesting that my two suggestions both generated a new web page on
the internet showing my solutions, both with files dated 1/21/2007!

Hi,

My sample "fails" just because it was made with a french version of XL
and in an english version XL translate Graphique as Chart. A workaround
is simply to rename the Chartobjects.

For your information, this sample is on the site www.excelabo.net since
2005, see
http://www.excelabo.net/moteurs/compteclic.php?nom=fl-cachegraph
 
R

rachitm

Thank you guys for all your help! this works..!!!

ShaneDevenshire a écrit :




The sample provide by François L, which was my other suggestion, fails not
because the idea is incorrect, but simply because thechartname is "Chart1"
not "Graphique 1".
You can use the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
If[PickList] = "Day1" Then
ChartObjects("Chart1").Visible = False
Else
ChartObjects("Chart1").Visible = True
EndIf
End Sub
(...)
Very interesting that my two suggestions both generated a new web page on
the internet showing my solutions, both with files dated 1/21/2007!Hi,

My sample "fails" just because it was made with a french version of XL
and in an english version XL translate Graphique asChart. A workaround
is simply to rename the Chartobjects.

For your information, this sample is on the sitewww.excelabo.netsince
2005, seehttp://www.excelabo.net/moteurs/compteclic.php?nom=fl-cachegraph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top