I have a bar c开发者_开发知识库hart 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?
This might get you started:
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
精彩评论