0

I have a bar chart in Excel 2007. I want to separately change the format of each bar in the chart, and then change it back to its original format. The overall effect is to make it look like each bar is being sequentially highlighted.

Is there a way to do this with VBA?

4

1 回答 1

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
于 2011-05-23T22:42:50.640 回答