怎样使用VBA随心所欲显示图表类型?
1、首先在开发工具中打开VBA编辑器

2、在单元格区域当中输入一些内容作为例子

3、在VBA编辑器中插入模块

4、在模块当中输入如下代码,然后运行
Private Sub Worksheet_Change(ByVal Target As Range)
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 If
End Sub

5、单击单元格E1,从下拉选项中选择任意名称,则图表立即更改为相应类型的图表

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:22
阅读量:41
阅读量:116
阅读量:49
阅读量:185