Creating Excel Animation With VBA Codes

Excel Animation Loop


         When first button is clicked, the circle shape moves to the right while turning itself around.

If second button is clicked ,this action is repeated 10 of times.Simple and beautiful loop example.

excel animation codes


excel animation sample

VBA codes to create animation:
Sub move1()
Dim i As Integer
With ActiveSheet.Shapes("Oval 1")
For i = 1 To 100
.IncrementLeft 0.75
.IncrementRotation 0.75
DoEvents
Next i
End With
End Sub

Sub move2()
Dim i As Integer
Dim j As Integer
With ActiveSheet.Shapes("Oval 1")
For j = 1 To 10
For i = 1 To 300
.IncrementLeft 0.75
.IncrementRotation 0.75
DoEvents
Next i
For i = 1 To 300
.IncrementLeft -0.75
.IncrementRotation -0.75
DoEvents
Next i
Next j
End With
End Sub

No comments:

Post a Comment