2015-06-29 95 views
1

我认为我的疑问很简单。我试图从VBA Excel中创建一个告知货币价值的饼图。我只能让它们显示为原始数字(例如不包含$,R $)。饼图 - 显示货币值 - Excel VBA

这里是我的代码:

With grafico_usp 
    .Name = "Metrics USP - Quantidade" 
    .ChartType = xlPieExploded 
    .SetSourceData Source:=rng 
    .ClearToMatchStyle 
    .ChartStyle = 304 
    .HasTitle = True 
    .HasLegend = True 
    .Legend.Format.TextFrame2.TextRange.Font.Size = 13 
    .Legend.Height = 200 
    .Legend.Position = xlLegendPositionRight 
    .ChartTitle.Text = "Estatística Número de Cursos Ofertados - USP" 
    .ApplyDataLabels (xlDataLabelsShowValue) 
End With 

我的电池也为货币格式,但单位没有出现在饼图英寸 感谢您的时间!

回答

0

这是微不足道的...... 我只是简单地记录了一个宏,它似乎适用于图表数据标签。在向导中,我首先添加了数据表。然后选择以数字格式通过选择货币格式化它们。

所以在VBA中,要达到相同的效果,如果您有多个数据系列,则必须将数字格式应用于每个数据系列。

ActiveSheet.ChartObjects("Chart 1").SeriesCollection(1).ApplyDataLabels 
With ActiveSheet.ChartObjects("Chart 1").SeriesCollection(1).DataLabels 
    .NumberFormat = "$#,##0.00" 
End With 

enter image description here