Before getting down to basics, the attached file:
Illustrates how Excel shapes can be simply animated.
The code for the animation (having previously drawn a circle and a rectangle with no fill, and noted their names):
Sub Animate()
Dim Start As Single, xInc As Single, yInc As Single, OvlWidth As Single, OvlHeight As Single
Dim OvlX As Single, OvlY As Single
Dim TopBox As Single, BottBox As Single, LeftBox As Single, RightBox As Single
Dim Pi As Double, TimeStep As Double, XV As Double, YV As Double
Pi = Atn(1) * 4
XV = Range(“hspeed”).Value
YV = Range(“vspeed”).Value
TimeStep = 0.01
With ActiveSheet.Shapes(“oval 2”)
OvlWidth = .Width
OvlHeight = .Height
End With
With ActiveSheet.Shapes(“rectangle 14”)
TopBox = .Top + OvlHeight / 2
BottBox = TopBox + .Height – OvlHeight
LeftBox = .Left + OvlWidth / 2
RightBox = LeftBox + .Width – OvlWidth
End With
xInc = XV * (RightBox – LeftBox) / 1000
yInc = YV * (BottBox – TopBox) / 1000
With ActiveSheet.Shapes("oval 2")
Do
.IncrementLeft xInc
.IncrementTop yInc
Start = Timer
Do While Timer < Start + TimeStep
DoEvents
Loop
OvlX = .Left + OvlWidth / 2
OvlY = .Top + OvlHeight / 2
If OvlX < LeftBox Or OvlX > RightBox Then xInc = -xInc
If OvlY < TopBox Or OvlY > BottBox Then yInc = -yInc
Loop
End With
End Sub
Where < and > indicate the “Less Than” and “Greater Than” symbols respectively.














