ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Change graph type (https://www.excelbanter.com/excel-discussion-misc-queries/60648-change-graph-type.html)

Steve

Change graph type
 
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


Steve

Change graph type
 
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


Pete

Change graph type
 
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


Steve

Change graph type
 
Pete

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

Steve



All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com