2015-06-29 94 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