Hide & Unhide Charts

  • Thread starter Thread starter vvaidya
  • Start date Start date
V

vvaidya

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
 
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
 

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

Back
Top