Microsoft Office Tutorials and References

In Depth Information

**Animating Charts**

Figure 18-20:
Range B7:C9 contains data point information that’s displayed in the text box on the chart.

The companion CD-ROM contains this example set up for an embedded chart

(
mouseover event - embedded.xlsm
) and for a chart sheet (
mouseover event -

chart sheet.xlsm
).

Animating Charts

Most people don’t realize it, but Excel is capable of performing simple animations. For example,

you can animate shapes and charts. Consider the XY chart shown in Figure 18-21.

The X values (column A) depend on the value in cell A1. The value in each row is the previous

row’s value plus the value in A1. Column B contains formulas that calculate the SIN of the

corresponding value in column A. The following simple procedure produces an interesting animation.

It uses a loop to continually change the value in cell A1, which causes the values in the X and Y

ranges to change. The effect is an animated chart.

Sub SimpleAnimation()

Dim i As Long

Range(“A1”) = 0

For i = 1 To 150

DoEvents

Range(“A1”) = Range(“A1”) + 0.035

DoEvents

Next i

Range(“A1”) = 0

End Sub