ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide & Unhide Charts (https://www.excelbanter.com/excel-programming/344971-hide-unhide-charts.html)

[email protected]

Hide & Unhide Charts
 
Hello:

I would appreciate help with the following:
I have about 5 different charts on a worksheet. Is there a way that I
can hide/unhide the charts so that I can display only one at a time.
I plan to use a List through 'Data', 'Validation', so that the user can
select the chart to be viewed from a drop down list (eg. Chart1,
Chart2,...... Chart5)

Thus when the user selects say Chart 2 from the drop down list, Chart2
is displayed & other charts are hidden.

TIA

Vinay


Rowan Drummond[_3_]

Hide & Unhide Charts
 
Try:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim chrt As ChartObject
If Target.Count = 1 And Target.Address = "$F$1" Then
For Each chrt In ActiveSheet.ChartObjects
If chrt.Name < Target.Value Then
chrt.Visible = False
Else
chrt.Visible = True
End If
Next chrt
End If
End Sub

This is worksheet event code. Right click the sheet tab, select View
Code and paste the code in there.
I have assumed that the Data Validation cell is in F1 - change as
required. Your list of names will need to match the names of the charts
exactly. If you have used the default names the probably "Chart 1",
"Chart 2" etc.

Hope this helps
Rowan

wrote:
Hello:

I would appreciate help with the following:
I have about 5 different charts on a worksheet. Is there a way that I
can hide/unhide the charts so that I can display only one at a time.
I plan to use a List through 'Data', 'Validation', so that the user can
select the chart to be viewed from a drop down list (eg. Chart1,
Chart2,...... Chart5)

Thus when the user selects say Chart 2 from the drop down list, Chart2
is displayed & other charts are hidden.

TIA

Vinay



All times are GMT +1. The time now is 08:45 PM.

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