{"id":1531,"date":"2013-12-17T07:44:40","date_gmt":"2013-12-17T07:44:40","guid":{"rendered":"http:\/\/excelvbatutor.com\/?page_id=1531"},"modified":"2019-04-19T07:56:19","modified_gmt":"2019-04-19T07:56:19","slug":"excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010","status":"publish","type":"page","link":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/","title":{"rendered":"Excel 2010 VBA Lesson 25: Creating Animation"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">&nbsp;<strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-24-creating-charts-and-graphs\/\">[Lesson 24]<\/a>&lt;&lt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&gt;&gt;&nbsp;<a title=\"excel vba2010 lesson 26\" href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-26-adding-and-manipulating-shapes\/\">[Lesson 26]<\/a><br>\n<\/strong><\/h4>\n\n\n\n<p>Besides creating Excel 2010&nbsp;VBA &nbsp; code for mathematical and financial calculations, it is also possible to create some fun applications in Excel 2010 VBA, including games and animation. Although professionals programmers might not be interested in writing such applications, it is worthwhile trying them out as a hobby and for personal satisfaction.<\/p>\n\n\n\n<script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Animation can be achieved by changing the position of an object continuously using a looping sub procedure.<\/p>\n\n\n\n<p>Two properties that are required to change the positions of the object are the Left and Top properties. The Left property specifies the distance between the left edge of the object in pixel from the left border of the screen and the Top property specifies the distance between the top edge of the object and the top border of the screen.The following code makes the object move from left to right then back to left again repeatedly until the user press the stop button. The reset button moves the object back to the starting position. You need to insert the image control into the spreadsheet in order for this code to work<br>\n<script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\n<strong>The code:<\/strong>\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Private Sub CmsStart_Click()\n\nrepeat:With VBAProject.Sheet1.Image1\n .Left = .Left + 1\nDoEvents\n If .Left &gt; 200 Then .Left = 1\nEnd WithGoTo repeat\n\nEnd Sub\n<\/pre>\n\n\n\n<p>The code for the reset button is\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Private Sub CmdReset_Click()\nWith VBAProject.Sheet1.Image1\n .Left = 0\nEnd With\nEnd Sub\n<\/pre>\n\n\n\n<p>*The above code reset the position of the image to the far left<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"540\" height=\"483\" src=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\" alt=\"vba2010_figure25.1\" class=\"wp-image-1536\"\/><\/a><\/figure><\/div>\n\n\n\n<p><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Figure 25.1<\/strong><\/p>\n\n\n\n<p>If you wish to move the object up and down, change the above code by replacing the property Left to Top, the code is as follows:\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Private Sub StartButton_Click()\nrepeat:With VBAProject.Sheet1.Image1\n.Top= .Top+ 1\nDoEvents\nIf .Top&gt; 200 Then .Top = 1\nEnd WithGoTo repeat\nEnd Sub\n<\/pre>\n\n\n\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\nIf you wish to make the object move diagonally, then use the properties Top and Left at the same time, as follows:\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Private Sub StartButton_Click()\nrepeat:\nWith VBAProject.Sheet1.Image1\n\n.Top = .Top + 5\n.Left = .Left + 5\n\nDoEvents\nIf .Top &gt; 200 Then .Top = 1\nIf .Left &gt; 200 Then .Left = 1\n\nEnd With\n\nGoTo repeat\nEnd Sub\n<\/pre>\n\n\n\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\n<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">&nbsp;&nbsp;<strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-24-creating-charts-and-graphs\/\">[Lesson 24]<\/a>&lt;&lt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&nbsp;&gt;&gt;<a title=\"excel vba2010 lesson 26\" href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-26-adding-and-manipulating-shapes\/\">[Lesson 26]<\/a><br>\n<\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;[Lesson 24]&lt;&lt;[Table of Contents]&gt;&gt;&nbsp;[Lesson 26] Besides creating Excel 2010&nbsp;VBA &nbsp; code for mathematical and financial calculations, it is also possible to create some fun applications in Excel 2010 VBA, including games and animation. Although professionals programmers might not be interested in writing such applications, it is worthwhile trying them out as a hobby and for &hellip; <a href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Excel 2010 VBA Lesson 25: Creating Animation&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5012,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-1531","page","type-page","status-publish","hentry","category-animation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor<\/title>\n<meta name=\"description\" content=\"This lesson illustrates how to create animation in excel 2010 VBA\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"og:description\" content=\"This lesson illustrates how to create animation in excel 2010 VBA\" \/>\n<meta property=\"og:url\" content=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-19T07:56:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"540\" \/>\n\t<meta property=\"og:image:height\" content=\"483\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\",\"url\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\",\"name\":\"Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"isPartOf\":{\"@id\":\"https:\/\/excelvbatutor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\",\"datePublished\":\"2013-12-17T07:44:40+00:00\",\"dateModified\":\"2019-04-19T07:56:19+00:00\",\"description\":\"This lesson illustrates how to create animation in excel 2010 VBA\",\"breadcrumb\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage\",\"url\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\",\"contentUrl\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg\",\"width\":540,\"height\":483},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/excelvbatutor.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel 2010 VBA Lesson 25: Creating Animation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/excelvbatutor.com\/#website\",\"url\":\"https:\/\/excelvbatutor.com\/\",\"name\":\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"description\":\"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"This lesson illustrates how to create animation in excel 2010 VBA","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/","og_locale":"en_US","og_type":"article","og_title":"Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","og_description":"This lesson illustrates how to create animation in excel 2010 VBA","og_url":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/","og_site_name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","article_modified_time":"2019-04-19T07:56:19+00:00","og_image":[{"width":540,"height":483,"url":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg","type":"image\/jpeg"}],"twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/","url":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/","name":"Excel 2010 VBA Lesson 25: Creating Animation - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","isPartOf":{"@id":"https:\/\/excelvbatutor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage"},"image":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage"},"thumbnailUrl":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg","datePublished":"2013-12-17T07:44:40+00:00","dateModified":"2019-04-19T07:56:19+00:00","description":"This lesson illustrates how to create animation in excel 2010 VBA","breadcrumb":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#primaryimage","url":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg","contentUrl":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure25.1.jpg","width":540,"height":483},{"@type":"BreadcrumbList","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-25-creating-animation-in-excel-vba-2010\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/excelvbatutor.com\/"},{"@type":"ListItem","position":2,"name":"Excel 2010 VBA Lesson 25: Creating Animation"}]},{"@type":"WebSite","@id":"https:\/\/excelvbatutor.com\/#website","url":"https:\/\/excelvbatutor.com\/","name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/users\/5012"}],"replies":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":37,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1531\/revisions"}],"predecessor-version":[{"id":3334,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1531\/revisions\/3334"}],"wp:attachment":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}