Link embedded chart to a commandbutton?

B

Bob

I have a embedded chart which I wish to show the chart when I press a
commandButton and hide the chart when I press either the same button or
another one.
 
A

Andy Pope

Hi,

The basic code would be, which will toggle visibility of first chartobject
on sheet.

Sub Button2_Click()

ActiveSheet.ChartObjects(1).Visible = Not
ActiveSheet.ChartObjects(1).Visible

End Sub

Cheers
Andy
 
A

Andy Pope

Probably because of the email formatting.

The syntax should be on 1 line.

Sub Button2_Click()

ActiveSheet.ChartObjects(1).Visible = _
Not ActiveSheet.ChartObjects(1).Visible
End Sub

Cheers
Andy
 
B

Bob

Andy thanks for that.
At the moment when I press the commanbutton(3) I can see the chart
underneath the active page?
 
A

Andy Pope

Sorry I don't understand what you mean?

On a worksheet enter 1,2,3 in cells A1:A3
Select A1:A3 and insert a chart on to the worksheet.
Using the Forms toolbar add a button to the worksheet.
Right click the button and assign macro.

The code should be in a standard code module.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Bob said:
Andy thanks for that.
At the moment when I press the commanbutton(3) I can see the chart
underneath the active page?
 
B

Bob

Andy,
I works well now Thanks very much
--
Bob


Andy Pope said:
Sorry I don't understand what you mean?

On a worksheet enter 1,2,3 in cells A1:A3
Select A1:A3 and insert a chart on to the worksheet.
Using the Forms toolbar add a button to the worksheet.
Right click the button and assign macro.

The code should be in a standard code module.

Cheers
Andy
 

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

Top