(Solved) – Animating movement of a worksheet Label

(solved)-–-animating-movement-of-a-worksheet-label

I’m trying to make a label move from one cell to another. I figured out the position offsets and created 3 “tweens” as animators call them. But when I run the code, the Label doesn’t display until the sub has ended. If I comment out the last position the label is in the right spot. How do I make Excel update the screen to show the label before I move it again?

xo and yo are integers either -1, 0, or 1. playerLocation is a range, might as well be ActiveCell.

Sub moveAnimation()

Dim moveAnim As OLEObject
Set moveAnim = Worksheets(currentSheet).OLEObjects(currentSheet & "player")

moveAnim.Left = playerLocation.Left - 0.5   yo * (playerLocation.Width / 4)
moveAnim.Top = playerLocation.Top   0.25   xo * (playerLocation.Width / 4)
Sleep (25)
moveAnim.Left = playerLocation.Left - 0.5   yo * (playerLocation.Width / 2)
moveAnim.Top = playerLocation.Top   0.25   xo * (playerLocation.Width / 2)
Sleep (25)
moveAnim.Left = playerLocation.Left - 0.5   yo * 3 * (playerLocation.Width / 4)
moveAnim.Top = playerLocation.Top   0.25   xo * 3 * (playerLocation.Width / 4)
Sleep (25)
moveAnim.Left = 0
moveAnim.Top = 0

Leave a Reply

Your email address will not be published. Required fields are marked *