How to Create Animation in Excel VBA (with Easy Steps)

Fortunately, many of us use Excel in our business organizations. In any business organization, we use Excel to organize data as per need and make databases for the future. Moreover, one interesting thing is that we can make animations very easily in Excel for better representation. However, I have used Microsoft Office 365 for the purpose of demonstration, and you can use other versions according to your preferences. In this article, I will show you a step-by-step procedure to create an Animation in Excel VBA. Hence, read through the article to learn more and save time.


Download Practice Workbook

You can download the workbook used for the demonstration from the download link below.


Step-by-Step Procedure to Create Animation in Excel VBA

Often, we need to utilize Excel to create animation, and the process becomes more interesting with Excel VBA. However, the task is easy and simple. But you will need an arrangement and a code in order to perform the operation properly. Hence, go through the following steps to create your desired animation using Excel VBA.


📌 Step 1: Select Sample Items for Animation in Excel

In this tutorial, I will show you a Football. Here, it will move when you press the Start button, and it will stop when you hit the Stop button. For the purpose of demonstration, I have chosen the following sample items to create the animation.

Animation in Excel VBA Sample Item

Read More: How to Create Animated Bar Chart Race in Excel (with Easy Steps)


📌 Step 2: Add Icons in Excel VBA to Create Animation

  • Firstly, go to the Insert tab.
  • Secondly, select Icons from the Illustrations.

Select Sample Items for Animation in Excel

  • Thirdly, write Start in the search box and select the icon.
  • Now, press Insert.

  • Fourthly, the button will appear below after some modifications.

  • Now, change the name of the icon to Start.

  • Similarly, add a Stop button as mentioned below and change the name to Stop.

  • Next, Click on Stock 3D Models, following a similar process mentioned above.

Select Sample Items for Animation in Excel

  • After that, select a Football from the searched items and select Insert.

  • However, it will appear like the below picture. Now, change the name to FootBall similarly.

  • Similarly, add a 3D Wall and a Grass Ground and change their name accordingly.

Add Icons to Create Animation in Excel VBA

Read More: How to Create 3D Animation in Excel


📌 Step 3: Insert VBA Code

  • In the beginning, select the Start button and right-click to enter the context menu.
  • Then, select Assign Macro.

Insert VBA Code to Create Animation in Excel

  • Next, hit New from the dialog box.

  • Afterward, a new window will open and write the following VBA macro in the Module.
Sub Start_Click()
x = 0
Do
DoEvents
x = x + 1
Sheet1.Shapes("FootBall").Left = x
Sheet1.Shapes("FootBall").Rotation = x
Loop Until x = 260 Or s
Do
DoEvents
x = x - 0.6
Sheet1.Shapes("FootBall").Left = x
Sheet1.Shapes("FootBall").Rotation = x
Loop Until x = 260
End Sub

  • Similarly, assign a macro in the Stop button.
Sub Sheet1_Stop_Click()
s = 0
End
End Sub

VBA Code to Create Animation in Excel


Final Output

Last but not least, press the Start button, and the Football will start moving. Then it will hit the Wall and come back to its initial position. However, it will continue rotation, and you can hit the Stop button to stop the ball. Moreover, you can stop the ball at any position by pressing the Stop button anytime.

Animation in Excel VBA


Conclusion

These are all the steps you can follow to create Animation in Excel VBA. Overall, in terms of working with time, we need this for various purposes. I have shown multiple methods with their respective examples, but there can be many other iterations depending on numerous situations. Hopefully, you can now easily create the needed adjustments. I sincerely hope you learned something and enjoyed this guide. Please let us know in the comments section below if you have any queries or recommendations.

For more information like this, visit Exceldemy.com.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Mehedi Hasan
Mehedi Hasan

Mehedi Hasan, a BSc graduate in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, plays a pivotal role as an Excel & VBA Content Developer at ExcelDemy. Fueled by a profound passion for research and innovation, he actively engages with Excel. In his capacity, Mehedi not only adeptly tackles intricate challenges but also showcases enthusiasm and expertise in navigating tough situations with finesse, underscoring his unwavering dedication to consistently delivering exceptional and high-quality content. He... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo