1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行Private Sub Worksheet_Cha艘绒庳焰nge(ByVal Target As Ra荏鱿胫协nge) If Target.Address="$E$2" Then ActiveSheet.ChartObjects("图表 2").Activate Select Case Target.Text Case "柱形图" ActiveChart.ChartType=xlColumnClustered Case "折线图" ActiveChart.ChartType=xlLineMarkers Case "面积图" ActiveChart.ChartType=xlArea Case "饼图" ActiveChart.ChartType=xlPie Case "圆环图" ActiveChart.ChartType=xlDoughnut Case "散点图" ActiveChart.ChartType=xlXYScatter End Select End IfEnd Sub
5、单击单元格E1,从下拉选项中选择任意名称,则图表立即更改为相应类型的图表