怎样使用VBA随心所欲显示图表类型
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,从下拉选项中选择任意名称,则图表立即更改为相应类型的图表
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:54
阅读量:64
阅读量:90
阅读量:43
阅读量:70