更改数据标签的日期类型

问题描述 投票:0回答:2

我一直在努力修复数据标签的数据类型格式。不幸的是,什么都没有解决。我希望数据标签的格式为0.00%。我该如何更改?

这里是程序的示例。

Dim OAPList As Range
Dim SingleCell As Range
Dim Counter As Integer

Set OAPList = Worksheets("Sheet2").Range("E2:E" & lw)
ActiveChart.FullSeriesCollection(1).ChartType = xlColumnClustered
ActiveChart.FullSeriesCollection(1).AxisGroup = 1
ActiveChart.SeriesCollection(1).HasDataLabels = True

Counter = 1
With ActiveChart.SeriesCollection(1)

    For Each SingleCell In OAPList
        ActiveChart.SeriesCollection(1).Points(Counter).DataLabel.Text = SingleCell.Value
        Counter = Counter + 1
    Next SingleCell
    .DataLabels.ShowValue = True
    .DataLabels.NumberFormat = "0%"
    '.DataLabels.Position = xlLabelPositionInsideEnd
    .DataLabels.Format.AutoShapeType = msoShapeRectangularCallout
    .DataLabels.Format.Line.Visible = msoTrue
End With

ActiveChart.SeriesCollection(2).Name = "Estimated Hours"
ActiveChart.FullSeriesCollection(2).ChartType = xlColumnClustered
ActiveChart.FullSeriesCollection(2).AxisGroup = 1

enter image description here

excel vba
2个回答
0
投票

尝试更改此行:

'With ActiveChart.SeriesCollection(1)
With ActiveChart.FullSeriesCollection(1)

0
投票

更改每个循环中的以下行:

ActiveChart.FullSeriesCollection(1).Points(Counter).DataLabel.Text = Format(SingleCell.Value, "0%")
© www.soinside.com 2019 - 2024. All rights reserved.