0

Wanted a way to change a graph type dynamically( without using VB script, is it even possible?) - say from bar to line or pie.

this will be triggered when a user clicks on a radio button or a drop down or any other way.

Beginner,Kindly help

4

1 回答 1

3

The best thing to do is create a simple chart, record a macro, and change the chart to several different types. Look at the recorded macro and you'll see the code you need to change the chart dynamically.

Here are a couple of examples that change the chart type, assuming your chart is called "Chart 1":

Sub ApplyPieChart()
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.ChartType = xlPie
End Sub

Sub ApplyBarChart()
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.ChartType = xlBarClustered
End Sub

You can then assign these macros to a button, a hyperlink, or whatever else you want.

Note that you can't change chart types with formulas. You will need to use VBA.

于 2012-05-30T12:36:16.930 回答