VBA Excel 2007 画饼图

1、在当前激活的sheet数据上画图,数据区域为A2:B6,运行效果如下:

2、源代码

Sub AddChart()
    
    '画饼图
    ActiveSheet.Shapes.AddChart.Select
    
    ActiveChart.ChartType = xlPie
    
    ActiveChart.SetSourceData Source:=Range("A2:B6")
    
    Set objChart = ActiveChart
    
    objChart.ChartType = 70

    objChart.Elevation = 30

    objChart.Rotation = 80

    objChart.ApplyDataLabels Type:=xlDataLabelsShowLabelAndPercent  '名称和百分比

    'xlDataLabelsShowPercent  '显示在整体中所占百分比的标签

   '去掉绘图区域或图表区域

    objChart.PlotArea.Fill.Visible = False

    objChart.PlotArea.Border.LineStyle = -4142

   '数据标签的大小、颜色、字体样式以及其它属性

    objChart.SeriesCollection(1).DataLabels.Font.Size = 10

    objChart.SeriesCollection(1).DataLabels.Font.ColorIndex = 6

    objChart.ChartArea.Fill.ForeColor.SchemeColor = 48

    objChart.ChartArea.Fill.BackColor.SchemeColor = 50

    objChart.ChartArea.Fill.TwoColorGradient 1, 1

    objChart.Legend.Shadow = True

    
End Sub


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值