设置图例文字饼图 [英] Set Legend Text Pie Chart

查看:198
本文介绍了设置图例文字饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用VBA宏设置我的两个传奇。



我想将我的两个传说从1和2改为我的馅饼的男性和女性通过将类别(X)轴标签设置为= Sheet1!$ B,可以通过将其设置在选择数据源对话框中,手动更改。 $ 6 $ $ 6(这是男女)



我如何使用VBA做这件事?



这是我的代码...

  Sub Pie()

对于X = 7到13
Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:= Sheets(Sheet1)。Range(b& X&:c& ; X)
ActiveChart.Location其中:= xlLocationAsObject,Name:=Sheet1
ActiveChart.HasTitle = True
CellVal = Worksheets(Sheet1)。Range(A& X).Value

ActiveChart.ChartTitle.Text =历史统计数据& CellVal

下一个X

End Sub


解决方案

请将 .SetSourceData方法更改为此:

  ActiveChart.SetSourceData Source:= Sheets(Sheet1)。Range(b6:c6&b& x&:c& x)


I have been trying to set my two legends using a VBA Macro.

I want to change my two legends from 1 and 2 to Male and Female on my Pie Chart.

I can change it manually by setting it in the "Select Data Source" dialog by setting "Category (X) axis labels" to "=Sheet1!$B$6:$C$6" (which is Male and Female)

How do I do this with VBA, though?

Here is my code...

Sub Pie()

    For X = 7 To 13
        Charts.Add
        ActiveChart.ChartType = xlPie
        ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("b" & X & ":c" & X)
        ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
        ActiveChart.HasTitle = True
        CellVal = Worksheets("Sheet1").Range("A" & X).Value

        ActiveChart.ChartTitle.Text = "History statistics of " & CellVal

    Next X

End Sub

解决方案

Pleas change the line with .SetSourceData method into this one:

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("b6:c6," & "b" & x & ":c" & x)

这篇关于设置图例文字饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆