Learn how to create simple animations in Excel VBA 365 by manipulating object positions. This guide includes practical code examples for horizontal, vertical, and diagonal movements.
Moves an object left-to-right continuously:
Private Sub CmsStart_Click() repeat: With VBAProject.Sheet1.Image1 .Left = .Left + 1 DoEvents If .Left > 200 Then .Left = 1 End With GoTo repeat End Sub
Private Sub StartButton_Click() repeat: With VBAProject.Sheet1.Image1 .Top = .Top + 1 DoEvents If .Top > 200 Then .Top = 1 End With GoTo repeat End Sub
Private Sub StartButton_Click() repeat: With VBAProject.Sheet1.Image1 .Top = .Top + 5 .Left = .Left + 5 DoEvents If .Top > 200 Then .Top = 1 If .Left > 200 Then .Left = 1 End With GoTo repeat End Sub
Copyright © 2008-2023 Dr. Liew Voon Kiong. All rights reserved.
Last updated:
Privacy Policy |
Contact via Facebook