在Excel 2007条形图中按顺序突出显示每个条形图

时间:2011-05-23 19:42:18

标签: vba format excel-2007 bar-chart

我在Excel 2007中有一个条形图。我想单独更改图表中每个条形的格式,然后将其更改回原始格式。总体效果是使每个条形图按顺序突出显示。

有没有办法用VBA做到这一点?

1 个答案:

答案 0 :(得分:1)

这可能会让你开始:

Sub Tester()

    Dim oCht As Excel.Chart, s As Series
    Dim x As Integer, i As Integer
    Dim oldColor As Long

    Set oCht = ActiveSheet.ChartObjects("Chart 1").Chart
    For x = 1 To oCht.SeriesCollection.Count
        Set s = oCht.SeriesCollection(x)
        For i = 1 To s.Points.Count
            With s.Points(i).Interior
                oldColor = .Color
                .Color = vbRed
                DoEvents
                Application.Wait Now + TimeSerial(0, 0, 2)
                .Color = oldColor
                DoEvents
            End With
        Next i
    Next x

End Sub