我一直在尝试用VBA宏来建立我的两个传奇。
我想把我的两个传说,从1和2改为男和女在我的派图。
我可以通过将“选择数据源”对话框中的“类别(X)轴标签”设置为“=Sheet1 1!$B$6:$C$6”(男性和女性)来手动更改它。
但是,我如何在VBA中做到这一点呢?
这是我的密码。
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发布于 2013-08-01 21:44:36
请将使用.SetSourceData method的行更改为以下一行:
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("b6:c6," & "b" & x & ":c" & x)https://stackoverflow.com/questions/18005023
复制相似问题