Change graph type

S

Steve

Hi

Is there a way to flip a graph type between, say, a bar and a pie chart
just by clicking a single on-screen user button? I know it's easy by
right-clicking the graph and selecting the appropriate option, but it's
an on-screen option I'm wondering about.

Thanks in advance

Steve
 
S

Steve

Sorry, to clarify. I can make the change once by using the following
command button code:

Private Sub CommandButton1_Click()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartType = xlLine
End Sub

However, what I want to do is revert back to the original format the
second time the command button is clicked.

Thanks

Steve
 
P

Pete

I think this will work. If you set up a variable, my_graph, and
initalise it to "xlLine", then you can toggle this between pie chart
and bar chart within your code and change the bottom line to:

ActiveChart.ChartType = my_graph

Pete
 
S

Steve

Pete

I had to experiment a bit as I wasn't sure quite what you meant, but
have managed it now. Thanks!

Steve
 
Top