Reputation: 392
I have a bunch of graphs on a single sheet. Also, I have a drop down menu of items. When I choose a particular item, I want to only show the graph associated with that item. How would I do this?
Here is a macro:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
ActiveSheet.ChartObjects.Visible = False
On Error Resume Next
ChartObjects(Target.Value).Visible = True
End If
End Sub
When I select the item from the drop down menu, I have to click on another cell and then click back on the drop down menu to get the graph to show. How do I get the graph to show instantaneously?
Upvotes: 1
Views: 47
Reputation: 861
I would create an ActiveX combobox instead (Developers tab->Insert->ComboBox).
Then instead of WorkSheet_Change use ComboBox1_Click() as event handler
You access the selected item with ComboBox1.value (assuming you don't change the default "ComboBox1" name).
Upvotes: 1