VBA – Animation with Excel

Animation consists of some pictures. In general, there are about 24 pictures per second, in order to do the “magic”. This could be easily automated with Excel, using  Application.Wait (Now + #12:00:01 AM#), if we agree to make it a bit old-fashioned, with 1 picture per second.

So, in general, we are having four pictures, that are simply following each other with 1 second in between them:

Here is the code, that generates these 4 pictures and make them loop as much as we want them:

How does it work? Using the RGB system in the colors, first the R is increased from 0 to 255. Once the is up to 255, the is started to increase from 0 to 255. At the end, the B is increased from 0 to 255. The steps in the WriteCircle are the reasons to have spaces between the cells in Excel. They are called from  WriteCircle 15, 1, 1  from the  Sub TestMe(). The one with 2,2 is the one that results in an empty column and empty row.

In general, naming variables like  Dim y&, x&, r&, g&, b& is stongly discouraged by anyone, but in this case, x is a great name for the horizontal axis of the coordinate system and in such a small example,  r,g,b are quite ok for red, green and blue.

Tagged with: , ,