ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if Cell B1 = "Day1" show chart (https://www.excelbanter.com/excel-programming/381599-if-cell-b1-%3D-day1-show-chart.html)

[email protected]

if Cell B1 = "Day1" show chart
 
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"
it would hide that chart?

Any help is appreciated!


okrob

if Cell B1 = "Day1" show chart
 
Paste this in the code for the worksheet if your chart is a worksheet.
If it's an object, you can replace the sheet visible statement with the

ActiveSheet.ChartObjects("Chartname").Visible = False

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$1" Then
If Target.Value = "Day1" Then
Sheets("Chart1").Visible = True ' <== change this if its
an object
Else
Sheets("Chart1").Visible = False ' <== change this if its
an object
End If
End If

End Sub

Rob



wrote:
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"
it would hide that chart?

Any help is appreciated!



Chip Pearson

if Cell B1 = "Day1" show chart
 
Right click the sheet tab and choose View Code. In the code module that
opens up, paste the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B1").Address Then
Me.ChartObjects(1).Visible = (StrComp("Day1", _
Target.Text, vbTextCompare) = 0)
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


wrote in message
ups.com...
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"
it would hide that chart?

Any help is appreciated!




[email protected]

if Cell B1 = "Day1" show chart
 
Thank You! This worked perfect!
Thanks a lot...

Chip Pearson wrote:
Right click the sheet tab and choose View Code. In the code module that
opens up, paste the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B1").Address Then
Me.ChartObjects(1).Visible = (StrComp("Day1", _
Target.Text, vbTextCompare) = 0)
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


wrote in message
ups.com...
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"
it would hide that chart?

Any help is appreciated!



Debra Dalgleish

if Cell B1 = "Day1" show chart
 
As answered in .charting:

You can do this with named ranges and a linked picture. There's a sample
file he

http://www.contextures.com/excelfiles.html

Under Charts, look for 'CH0002 - Show or Hide Chart'

wrote:
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"
it would hide that chart?

Any help is appreciated!



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com