chart display using buttons

paulinenj

New Member
Joined
Oct 2, 2006
Messages
25
I have one sheet of data that refers to multiple other sheets of data. From that one sheet I am creating charts with drop down lists to select the cases the individual wants to use. I have 3 different charts that I need to make and I would like to put them on the same sheet, so as not to confuse the vlookup with different drop downs. I would like to make one chart visible at a time, using a button (or some other tool) to change the chart being displayed. :confused:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi

Hope this may get you going. It is a commandbutton from the controls toolbar. In the code, there is only 1 chart on the sheet. If you change the index to refer to the specific chart you could also change the caption on the button to suit.

Code:
Private Sub CommandButton1_Click()
  Sheets("sheet1").ChartObjects(1).Visible = Not (Sheets("sheet1").ChartObjects(1).Visible)
  If Sheets("sheet1").ChartObjects(1).Visible Then
    res = "Hide"
  Else
    res = "Show"
  End If
  CommandButton1.Caption = "Chart1 " & res
End Sub


Tony
 
Upvote 0
Thanks,

I am just getting familiar with this code....what does "res" refer to? and does "ChartObjects(1)" just refer to the chart on that page?
 
Upvote 0
HI

res is a variable that is used to house the Hide / Show text for the button caption.

chartobject(1) refers to the chart on that sheet. If there is only 1 chart, then it will select it. If there are multiple charts, then it will select one of them. That is why I suggested you get the name of the chart, and use it instead of the index.


Tony
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,725
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top