<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Excel Optimize &#187; VBA Excel</title>
	<atom:link href="http://exceloptimize.com/category/vba/feed" rel="self" type="application/rss+xml" />
	<link>http://exceloptimize.com</link>
	<description>Tips Formula, Macro, and VBA on Microsoft Excel</description>
	<lastBuildDate>Sat, 26 Dec 2009 14:32:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Loading Add-ins Automatically</title>
		<link>http://exceloptimize.com/vba/loading-add-ins-automatically.html</link>
		<comments>http://exceloptimize.com/vba/loading-add-ins-automatically.html#comments</comments>
		<pubDate>Sat, 19 Dec 2009 00:39:28 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[add-ins]]></category>
		<category><![CDATA[load add-ins automatically]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=394</guid>
		<description><![CDATA[This tips will give you steps on how to selectively load add-ins in specific worksheet, we&#8217;re able to do this on with a little code on macro. Here&#8217;s the steps:

Activate the worksheet in which you want an add-in to be loaded.
Press the shortcut button  Alt+F11 to display the VBA Editor or click on Developer ribbon [...]]]></description>
			<content:encoded><![CDATA[<p>This tips will give you steps on how to selectively load add-ins in specific worksheet, we&#8217;re able to do this on with a little code on macro. Here&#8217;s the steps:</p>
<ol>
<li>Activate the worksheet in which you want an add-in to be loaded.</li>
<li>Press the shortcut button  <strong>Alt+F11</strong> to display the VBA Editor or click on Developer ribbon and then click the Visual Basic button on the left hand side.</li>
<li>Double-click on the &#8220;This Workbook&#8221; object in the Project Explorer. Excel opens a code window for This Workbook.</li>
<li>Put the following code into macro windows you have loaded:</li>
</ol>
<blockquote>
<pre>Private Sub Workbook_BeforeClose(Cancel As Boolean)
    AddIns("Add-In Name").Installed = False
End Sub</pre>
<pre>Private Sub Workbook_Open()
    AddIns("Add-In Name").Installed = True
End Sub</pre>
</blockquote>
<ol>
<li>In the code, change the name of the add-ins (&#8221;Add-In Name&#8221;) to the real name of the add-in you want to use with the worksheet.</li>
<li>Close the VBA Editor.</li>
<li>Save your worksheet.</li>
</ol>
<p>If you are not sure of the correct name for a particular add-in (see step 5), you can use the macro recorder function<a id="KonaLink1" style="text-decoration: underline ! important; position: static;" href="http://excel.tips.net/Pages/T002016_Automatically_Loading_Addins.html#" target="undefined"></a> to record the process of activating an add-in. That will show you the exact name you should use in the above macros.<br />
<h3>Related Post</h3>
<ul class="related_post">
<li>Related Post</li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;Title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;submitHeadline=Loading+Add-ins+Automatically&amp;submitSummary=This%20tips%20will%20give%20you%20steps%20on%20how%20to%20selectively%20load%20add-ins%20in%20specific%20worksheet%2C%20we%27re%20able%20to%20do%20this%20on%20with%20a%20little%20code%20on%20macro.%20Here%27s%20the%20steps%3A%0D%0A%0D%0A%09Activate%20the%20worksheet%20in%20which%20you%20want%20an%20add-in%20to%20be%20loaded.%0D%0A%09Press%20the%20shortcut%20button%C2%A0%20Alt%2BF11%20to%20display%20the%20VBA%20Editor%20or%20clic&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/loading-add-ins-automatically.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;t=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Loading+Add-ins+Automatically+-+http://b2l.me/bs6h8+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;bm_description=Loading+Add-ins+Automatically&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Loading+Add-ins+Automatically&amp;link=http://exceloptimize.com/vba/loading-add-ins-automatically.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;type=Article&amp;title=Loading+Add-ins+Automatically" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/loading-add-ins-automatically.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/loading-add-ins-automatically.html&amp;n=Loading+Add-ins+Automatically&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/loading-add-ins-automatically.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do-Until loop</title>
		<link>http://exceloptimize.com/vba/do-until-loop.html</link>
		<comments>http://exceloptimize.com/vba/do-until-loop.html#comments</comments>
		<pubDate>Thu, 07 May 2009 11:07:15 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[Do-until loop]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=343</guid>
		<description><![CDATA[The Do-Until loop structure is similar to the Do-While structure. The two structures differ in their handling of the tested condition. A program continues to execute a Do-While loop while the condition remains true. In a Do-Until loop, the program executes the loop until the condition is true. Here’s the Do-Until syntax:

Do [Until condition]
statements]
[Exit Do]
[statements]
Loop
The [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The Do-Until loop structure is similar to the Do-While structure. The two structures differ in their handling of the tested condition. A program continues to execute a Do-While loop while the condition remains true. In a Do-Until loop, the program executes the loop until the condition is true. Here’s the Do-Until syntax:</p>
<blockquote>
<p style="text-align: justify;">Do [Until condition]<br />
statements]<br />
[Exit Do]<br />
[statements]<br />
Loop</p></blockquote>
<p style="text-align: justify;">The following example is the same one presented for the Do-While loop but recoded to use a Do-Until loop:</p>
<blockquote>
<p style="text-align: justify;">Sub DoUntilDemo()<br />
Do Until IsEmpty(ActiveCell.Value)<br />
ActiveCell.Value = ActiveCell.Value * 2<br />
ActiveCell.Offset(1, 0).Select<br />
Loop<br />
End Sub</p></blockquote>
<p style="text-align: justify;">Just like with the Do-While loop, you may encounter a different form of the Do-Until loop — a Do-Loop Until loop. The following example, which has the same effect as the preceding procedure, demonstrates an alternate syntax for this type of loop:</p>
<blockquote>
<p style="text-align: justify;">Sub DoLoopUntilDemo()<br />
Do<br />
ActiveCell.Value = ActiveCell.Value * 2<br />
ActiveCell.Offset(1, 0).Select<br />
Loop Until IsEmpty(ActiveCell.Value)<br />
End Sub</p></blockquote>
<p style="text-align: justify;">There is a subtle difference in how the Do-Until loop and the Do-Loop Until loop operate. In the former, the test is performed at the beginning of the loop, before anything in the body of the loop is executed. This means that it is possible that the code in the loop body will not be executed if the test condition is met. In the latter version, the condition is tested at the end of the loop. Therefore, at a minimum, the Do-Loop Until loop always results in the body of the loop being executed once.</p>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/do-while-loop.html" title="Do-While loop">Do-While loop</a></li>
<li><a href="http://exceloptimize.com/vba/nested-for-next.html" title="Nested For-Next">Nested For-Next</a></li>
<li><a href="http://exceloptimize.com/vba/looping-code.html" title="Looping Code">Looping Code</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/do-until-loop.html&amp;Title=Do-Until+loop" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/do-until-loop.html&amp;title=Do-Until+loop" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/do-until-loop.html&amp;title=Do-Until+loop" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/do-until-loop.html&amp;title=Do-Until+loop" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/do-until-loop.html&amp;submitHeadline=Do-Until+loop&amp;submitSummary=The%20Do-Until%20loop%20structure%20is%20similar%20to%20the%20Do-While%20structure.%20The%20two%20structures%20differ%20in%20their%20handling%20of%20the%20tested%20condition.%20A%20program%20continues%20to%20execute%20a%20Do-While%20loop%20while%20the%20condition%20remains%20true.%20In%20a%20Do-Until%20loop%2C%20the%20program%20executes%20the%20loop%20until%20the%20condition%20is%20true.%20Here%E2&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/do-until-loop.html&amp;title=Do-Until+loop" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/do-until-loop.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/do-until-loop.html&amp;t=Do-Until+loop" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Do-Until+loop+-+http://b2l.me/bpq3a+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/do-until-loop.html&amp;bm_description=Do-Until+loop&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Do-Until+loop&amp;link=http://exceloptimize.com/vba/do-until-loop.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/do-until-loop.html&amp;type=Article&amp;title=Do-Until+loop" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/do-until-loop.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/do-until-loop.html&amp;n=Do-Until+loop&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/do-until-loop.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do-While loop</title>
		<link>http://exceloptimize.com/vba/do-while-loop.html</link>
		<comments>http://exceloptimize.com/vba/do-while-loop.html#comments</comments>
		<pubDate>Tue, 05 May 2009 10:31:11 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[do-while]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=335</guid>
		<description><![CDATA[VBA supports another type of looping structure known as a Do-While loop. Unlike a For-Next loop, a Do-While loop continues until a specified condition is met. Here’s the Do-While loop syntax:

Do [While condition]
[statements]
[Exit Do]
[statements]
Loop
The following example uses a Do-While loop. This routine uses the active cell as a starting point and then travels down the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">VBA supports another type of looping structure known as a Do-While loop. Unlike a For-Next loop, a Do-While loop continues until a specified condition is met. Here’s the Do-While loop syntax:</p>
<blockquote>
<p style="text-align: justify;">Do [While condition]<br />
[statements]<br />
[Exit Do]<br />
[statements]<br />
Loop</p></blockquote>
<p style="text-align: justify;">The following example uses a Do-While loop. This routine uses the active cell as a starting point and then travels down the column, multiplying each cell’s value by 2. The loop continues until the routine encounters an empty cell.</p>
<blockquote>
<p style="text-align: justify;">Sub DoWhileDemo()<br />
Do While ActiveCell.Value &lt;&gt; Empty<br />
ActiveCell.Value = ActiveCell.Value * 2<br />
ActiveCell.Offset(1, 0).Select<br />
Loop<br />
End Sub</p></blockquote>
<p style="text-align: justify;">Some people prefer to code a Do-While loop as a Do-Loop While loop. This example performs exactly as the previous procedure but uses a different loop syntax:</p>
<blockquote>
<p style="text-align: justify;">Sub DoLoopWhileDemo()<br />
Do<br />
ActiveCell.Value = ActiveCell.Value * 2<br />
ActiveCell.Offset(1, 0).Select<br />
Loop While ActiveCell.Value &lt;&gt; Empty<br />
End Sub</p></blockquote>
<p style="text-align: justify;">Remember this key difference between the Do-While and Do-Loop While loops: The Do-While loop always performs its conditional test first. If the test is not true, the instructions inside the loop are never executed. The Do-Loop While loop, on the other hand, always performs its conditional test after the instructions inside the loop are executed. Thus, the loop instructions are always executed at least once, regardless of the test. This difference can have a profound effect on how your program functions.</p>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/do-until-loop.html" title="Do-Until loop">Do-Until loop</a></li>
<li><a href="http://exceloptimize.com/vba/nested-for-next.html" title="Nested For-Next">Nested For-Next</a></li>
<li><a href="http://exceloptimize.com/vba/looping-code.html" title="Looping Code">Looping Code</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/do-while-loop.html&amp;Title=Do-While+loop" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/do-while-loop.html&amp;title=Do-While+loop" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/do-while-loop.html&amp;title=Do-While+loop" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/do-while-loop.html&amp;title=Do-While+loop" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/do-while-loop.html&amp;submitHeadline=Do-While+loop&amp;submitSummary=VBA%20supports%20another%20type%20of%20looping%20structure%20known%20as%20a%20Do-While%20loop.%20Unlike%20a%20For-Next%20loop%2C%20a%20Do-While%20loop%20continues%20until%20a%20specified%20condition%20is%20met.%20Here%E2%80%99s%20the%20Do-While%20loop%20syntax%3A%0D%0A%0D%0A%0D%0ADo%20%5BWhile%20condition%5D%0D%0A%5Bstatements%5D%0D%0A%5BExit%20Do%5D%0D%0A%5Bstatements%5D%0D%0ALoop%0D%0AThe%20following%20example%20uses%20a%20Do-Wh&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/do-while-loop.html&amp;title=Do-While+loop" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/do-while-loop.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/do-while-loop.html&amp;t=Do-While+loop" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Do-While+loop+-+http://b2l.me/bpq3b+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/do-while-loop.html&amp;bm_description=Do-While+loop&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Do-While+loop&amp;link=http://exceloptimize.com/vba/do-while-loop.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/do-while-loop.html&amp;type=Article&amp;title=Do-While+loop" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/do-while-loop.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/do-while-loop.html&amp;n=Do-While+loop&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/do-while-loop.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nested For-Next</title>
		<link>http://exceloptimize.com/vba/nested-for-next.html</link>
		<comments>http://exceloptimize.com/vba/nested-for-next.html#comments</comments>
		<pubDate>Mon, 04 May 2009 10:23:47 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=330</guid>
		<description><![CDATA[
So far, all this chapter’s examples use relatively simple loops. However, you can have any number of statements in the loop and nest For-Next loops inside other For-Next loops. The following example uses a nested For-Next loop to insert random numbers into a 12-row-x-5-column range of cells, as shown in Figure 10-2. Notice that the [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><img class="aligncenter size-full wp-image-331" title="Looping" src="http://exceloptimize.com/wp-content/uploads/2009/04/10-2.jpg" alt="Looping" width="320" height="193" /></p>
<p style="text-align: justify;">So far, all this chapter’s examples use relatively simple loops. However, you can have any number of statements in the loop and nest For-Next loops inside other For-Next loops. The following example uses a nested For-Next loop to insert random numbers into a 12-row-x-5-column range of cells, as shown in Figure 10-2. Notice that the routine executes the inner loop (the loop with the Row counter) once for each iteration of the outer loop (the loop with the Col counter). In other words, the routine executes the Cells(Row, Col) = Rnd statement 60 times.</p>
<blockquote>
<p style="text-align: justify;">Sub FillRange2()<br />
Dim Col As Long<br />
Dim Row As Long<br />
For Col = 1 To 5<br />
For Row = 1 To 12<br />
Cells(Row, Col) = Rnd<br />
Next Row<br />
Next Col<br />
End Sub</p></blockquote>
<p style="text-align: justify;">The next example uses nested For-Next loops to initialize a three-dimensional array with zeros. This routine executes the statement in the middle of all the loops (the assignment statement) 1,000 times, each time with a different combination of values for i, j, and k:</p>
<blockquote>
<p style="text-align: justify;">Sub NestedLoops()<br />
Dim MyArray(10, 10, 10)<br />
Dim i As Integer<br />
Dim j As Integer<br />
Dim k As Integer<br />
For i = 1 To 10<br />
For j = 1 To 10<br />
For k = 1 To 10<br />
MyArray(i, j, k) = 0<br />
Next k<br />
Next j<br />
Next i<br />
End Sub</p></blockquote>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/looping-code.html" title="Looping Code">Looping Code</a></li>
<li><a href="http://exceloptimize.com/vba/do-until-loop.html" title="Do-Until loop">Do-Until loop</a></li>
<li><a href="http://exceloptimize.com/vba/do-while-loop.html" title="Do-While loop">Do-While loop</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/nested-for-next.html&amp;Title=Nested+For-Next" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/nested-for-next.html&amp;title=Nested+For-Next" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/nested-for-next.html&amp;title=Nested+For-Next" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/nested-for-next.html&amp;title=Nested+For-Next" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/nested-for-next.html&amp;submitHeadline=Nested+For-Next&amp;submitSummary=%0D%0ASo%20far%2C%20all%20this%20chapter%E2%80%99s%20examples%20use%20relatively%20simple%20loops.%20However%2C%20you%20can%20have%20any%20number%20of%20statements%20in%20the%20loop%20and%20nest%20For-Next%20loops%20inside%20other%20For-Next%20loops.%20The%20following%20example%20uses%20a%20nested%20For-Next%20loop%20to%20insert%20random%20numbers%20into%20a%2012-row-x-5-column%20range%20of%20cells%2C%20as%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/nested-for-next.html&amp;title=Nested+For-Next" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/nested-for-next.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/nested-for-next.html&amp;t=Nested+For-Next" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Nested+For-Next+-+http://b2l.me/bpq3c+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/nested-for-next.html&amp;bm_description=Nested+For-Next&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Nested+For-Next&amp;link=http://exceloptimize.com/vba/nested-for-next.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/nested-for-next.html&amp;type=Article&amp;title=Nested+For-Next" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/nested-for-next.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/nested-for-next.html&amp;n=Nested+For-Next&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/nested-for-next.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>For-Next with an Exit For statement</title>
		<link>http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html</link>
		<comments>http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html#comments</comments>
		<pubDate>Sun, 03 May 2009 10:18:11 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[For-Next]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=326</guid>
		<description><![CDATA[A For-Next loop can also include one or more Exit For statements within the loop. When VBA encounters this statement, the loop terminates immediately. The following example, available on the book’s Web site, demonstrates the Exit For statement. This routine identifies which of the active worksheet’s cells in column A has the largest value:

Sub ExitForDemo()
Dim [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">A For-Next loop can also include one or more Exit For statements within the loop. When VBA encounters this statement, the loop terminates immediately. The following example, available on the book’s Web site, demonstrates the Exit For statement. This routine identifies which of the active worksheet’s cells in column A has the largest value:</p>
<blockquote>
<p style="text-align: justify;">Sub ExitForDemo()<br />
Dim MaxVal As Double<br />
Dim Row As Long<br />
MaxVal = Application.WorksheetFunction. _<br />
Max(Range(“A:A”))<br />
For Row = 1 To Rows.Count<br />
If Range(“A1”).Offset(Row &#8211; 1, 0).Value = MaxVal<br />
Then<br />
Range(“A1”).Offset(Row &#8211; 1, 0).Activate<br />
MsgBox “Max value is in Row “ &amp; Row<br />
Exit For<br />
End If<br />
Next Row<br />
End Sub</p></blockquote>
<p style="text-align: justify;">The routine calculates the maximum value in the column by using Excel’s MAX function and assigns the result to the MaxVal variable. The For-Next loop then checks each cell in the column. If the cell being checked is equal to MaxVal, the routine doesn’t need to continue looping (its job is finished), so the Exit For statement terminates the loop. Before terminating the loop, the procedure activates the cell with the maximum value and informs the user of its location. Notice that I use Rows.Count in the For statement. The count property of the Rows objects returns the number of rows in the worksheet. Therefore, you can use this procedure with Excel 2007 as well as with earlier versions (which have fewer rows).</p>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/for-next-with-a-step.html" title="For-Next with a Step">For-Next with a Step</a></li>
<li><a href="http://exceloptimize.com/vba/nested-for-next.html" title="Nested For-Next">Nested For-Next</a></li>
<li><a href="http://exceloptimize.com/vba/for-next-loops.html" title="For-Next loops">For-Next loops</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;Title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;submitHeadline=For-Next+with+an+Exit+For+statement&amp;submitSummary=A%20For-Next%20loop%20can%20also%20include%20one%20or%20more%20Exit%20For%20statements%20within%20the%20loop.%20When%20VBA%20encounters%20this%20statement%2C%20the%20loop%20terminates%20immediately.%20The%20following%20example%2C%20available%20on%20the%20book%E2%80%99s%20Web%20site%2C%20demonstrates%20the%20Exit%20For%20statement.%20This%20routine%20identifies%20which%20of%20the%20active%20worksheet&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;t=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=For-Next+with+an+Exit+For+statement+-+http://b2l.me/bpq3d+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;bm_description=For-Next+with+an+Exit+For+statement&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=For-Next+with+an+Exit+For+statement&amp;link=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;type=Article&amp;title=For-Next+with+an+Exit+For+statement" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html&amp;n=For-Next+with+an+Exit+For+statement&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>For-Next with a Step</title>
		<link>http://exceloptimize.com/vba/for-next-with-a-step.html</link>
		<comments>http://exceloptimize.com/vba/for-next-with-a-step.html#comments</comments>
		<pubDate>Fri, 01 May 2009 10:14:49 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[For-Next]]></category>
		<category><![CDATA[looping]]></category>
		<category><![CDATA[VBA code]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=324</guid>
		<description><![CDATA[You can use a Step value to skip some values in a For-Next loop. Here’s the same procedure as in the preceding section, rewritten to insert random numbers into every other cell:

Sub FillRange()
Dim Count As Long
For Count = 1 To 100 Step 2
ActiveCell.Offset(Count &#8211; 1, 0) = Rnd
Next Count
End Sub
This time, Count starts out as [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">You can use a Step value to skip some values in a For-Next loop. Here’s the same procedure as in the preceding section, rewritten to insert random numbers into every other cell:</p>
<blockquote>
<p style="text-align: justify;">Sub FillRange()<br />
Dim Count As Long<br />
For Count = 1 To 100 Step 2<br />
ActiveCell.Offset(Count &#8211; 1, 0) = Rnd<br />
Next Count<br />
End Sub</p></blockquote>
<p style="text-align: justify;">This time, Count starts out as 1 and then takes on a value of 3, 5, 7, and so on. The final Count value is 99. The Step value determines how the counter is incremented.<br />
This chapter introduces looping via the BadLoop example, which uses a GoTo statement. Here’s the same example, which is available on this book’s Web site, converted into a good loop by using the For-Next structure:</p>
<blockquote>
<p style="text-align: justify;">Sub FillRange()<br />
Dim StartVal As Long<br />
Dim NumToFill As Long<br />
Dim CellCount As Long<br />
StartVal = InputBox(“Enter the starting value: “)<br />
NumToFill = InputBox(“How many cells? “)<br />
For CellCount = 1 To NumToFill<br />
ActiveCell.Offset(CellCount &#8211; 1, 0) = _<br />
StartVal + CellCount &#8211; 1<br />
Next CellCount<br />
End Sub</p></blockquote>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html" title="For-Next with an Exit For statement">For-Next with an Exit For statement</a></li>
<li><a href="http://exceloptimize.com/vba/looping-through-the-chartobjects-collection.html" title="Looping through the ChartObjects collection">Looping through the ChartObjects collection</a></li>
<li><a href="http://exceloptimize.com/vba/looping-through-a-range-efficiently.html" title="Looping through a range efficiently">Looping through a range efficiently</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;Title=For-Next+with+a+Step" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;title=For-Next+with+a+Step" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;title=For-Next+with+a+Step" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;title=For-Next+with+a+Step" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;submitHeadline=For-Next+with+a+Step&amp;submitSummary=You%20can%20use%20a%20Step%20value%20to%20skip%20some%20values%20in%20a%20For-Next%20loop.%20Here%E2%80%99s%20the%20same%20procedure%20as%20in%20the%20preceding%20section%2C%20rewritten%20to%20insert%20random%20numbers%20into%20every%20other%20cell%3A%0D%0A%0D%0A%0D%0ASub%20FillRange%28%29%0D%0ADim%20Count%20As%20Long%0D%0AFor%20Count%20%3D%201%20To%20100%20Step%202%0D%0AActiveCell.Offset%28Count%20-%201%2C%200%29%20%3D%20Rnd%0D%0ANext%20Count%0D&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;title=For-Next+with+a+Step" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/for-next-with-a-step.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;t=For-Next+with+a+Step" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=For-Next+with+a+Step+-+http://b2l.me/bpq3e+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;bm_description=For-Next+with+a+Step&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=For-Next+with+a+Step&amp;link=http://exceloptimize.com/vba/for-next-with-a-step.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;type=Article&amp;title=For-Next+with+a+Step" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/for-next-with-a-step.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/for-next-with-a-step.html&amp;n=For-Next+with+a+Step&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/for-next-with-a-step.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>For-Next loops</title>
		<link>http://exceloptimize.com/vba/for-next-loops.html</link>
		<comments>http://exceloptimize.com/vba/for-next-loops.html#comments</comments>
		<pubDate>Wed, 29 Apr 2009 10:13:53 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[For-Next]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=320</guid>
		<description><![CDATA[The simplest type of loop is a For-Next loop. Here’s the syntax for this structure:

For counter = start To end [Step stepval]
[statements]
[Exit For]
[statements]
Next [counter]
The looping is controlled by a counter variable, which starts at one value and stops at another value. The statements between the For statement and the Next statement are the statements that [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The simplest type of loop is a For-Next loop. Here’s the syntax for this structure:</p>
<blockquote>
<p style="text-align: justify;">For counter = start To end [Step stepval]<br />
[statements]<br />
[Exit For]<br />
[statements]<br />
Next [counter]</p></blockquote>
<p style="text-align: justify;">The looping is controlled by a counter variable, which starts at one value and stops at another value. The statements between the For statement and the Next statement are the statements that get repeated in the loop. To see how<br />
this works, keep reading.</p>
<p style="text-align: justify;"><strong>A For-Next example</strong><br />
The following example shows a For-Next loop that doesn’t use the optional Step value or the optional Exit For statement. This routine loops 100 times and uses the VBA Rnd function to enter a random number into 100 cells:</p>
<blockquote>
<p style="text-align: justify;">Sub FillRange()<br />
Dim Count As Long<br />
For Count = 1 To 100<br />
ActiveCell.Offset(Count &#8211; 1, 0) = Rnd<br />
Next Count<br />
End Sub</p></blockquote>
<p style="text-align: justify;">In this example, Count (the loop counter variable) starts with a value of 1 and increases by 1 each time through the loop. Because I didn’t specify a Step value, VBA uses the default value (1). The Offset method uses the value of Count as an argument. The first time through the loop, the procedure enters a number into the active cell offset by zero rows. The second time through (Count = 2), the procedure enters a number into the active cell offset by one row (Count –1), and so on. Because the loop counter is a normal variable, you can change its value within the block of code between the For and the Next statements. This, however, is a very bad practice. Changing the counter within the loop can have<br />
unpredictable results. Take special precautions to ensure that your code does not directly change the value of the loop counter.<br />
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/for-next-with-an-exit-for-statement.html" title="For-Next with an Exit For statement">For-Next with an Exit For statement</a></li>
<li><a href="http://exceloptimize.com/vba/for-next-with-a-step.html" title="For-Next with a Step">For-Next with a Step</a></li>
<li><a href="http://exceloptimize.com/vba/do-until-loop.html" title="Do-Until loop">Do-Until loop</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/for-next-loops.html&amp;Title=For-Next+loops" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/for-next-loops.html&amp;title=For-Next+loops" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/for-next-loops.html&amp;title=For-Next+loops" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/for-next-loops.html&amp;title=For-Next+loops" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/for-next-loops.html&amp;submitHeadline=For-Next+loops&amp;submitSummary=The%20simplest%20type%20of%20loop%20is%20a%20For-Next%20loop.%20Here%E2%80%99s%20the%20syntax%20for%20this%20structure%3A%0D%0A%0D%0A%0D%0AFor%20counter%20%3D%20start%20To%20end%20%5BStep%20stepval%5D%0D%0A%5Bstatements%5D%0D%0A%5BExit%20For%5D%0D%0A%5Bstatements%5D%0D%0ANext%20%5Bcounter%5D%0D%0AThe%20looping%20is%20controlled%20by%20a%20counter%20variable%2C%20which%20starts%20at%20one%20value%20and%20stops%20at%20another%20value.%20The%20sta&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/for-next-loops.html&amp;title=For-Next+loops" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/for-next-loops.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/for-next-loops.html&amp;t=For-Next+loops" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=For-Next+loops+-+http://b2l.me/bpq3f+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/for-next-loops.html&amp;bm_description=For-Next+loops&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=For-Next+loops&amp;link=http://exceloptimize.com/vba/for-next-loops.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/for-next-loops.html&amp;type=Article&amp;title=For-Next+loops" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/for-next-loops.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/for-next-loops.html&amp;n=For-Next+loops&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/for-next-loops.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looping Code</title>
		<link>http://exceloptimize.com/vba/looping-code.html</link>
		<comments>http://exceloptimize.com/vba/looping-code.html#comments</comments>
		<pubDate>Tue, 28 Apr 2009 10:20:37 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[looping]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/?p=328</guid>
		<description><![CDATA[The term looping refers to repeating a block of VBA statements numerous times. You may know how many times your program needs to loop, or variables used in your program’s code may determine this. There are two types of loops: good loops and bad loops. (Good loops get rewarded, and bad loops get sent to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The term looping refers to repeating a block of VBA statements numerous times. You may know how many times your program needs to loop, or variables used in your program’s code may determine this. There are two types of loops: good loops and bad loops. (Good loops get rewarded, and bad loops get sent to their room.) The following code demonstrates a bad loop. The procedure simply enters consecutive numbers into a range. It starts by prompting the user for two values: a starting value and the total number of cells to fill. (Because InputBox returns a string, I convert the strings to integers by using the CInt function.) This loop uses the GoTo statement to control the flow. The CellCount variable keeps track of how many cells are filled. If this value is less than the number requested by the user, program control loops back to DoAnother.</p>
<blockquote>
<p style="text-align: justify;">Sub BadLoop()<br />
Dim StartVal As Long<br />
Dim NumToFill As Long<br />
Dim CellCount As Long<br />
StartVal = InputBox(“Enter the starting value: “)<br />
NumToFill = InputBox(“How many cells? “)<br />
ActiveCell = StartVal<br />
CellCount = 1<br />
DoAnother:<br />
ActiveCell.Offset(CellCount, 0) = StartVal + CellCount<br />
CellCount = CellCount + 1<br />
If CellCount &lt; NumToFill Then GoTo DoAnother _<br />
Else Exit Sub<br />
End Sub</p></blockquote>
<p style="text-align: justify;">This routine works as intended, so why is it an example of bad looping? As I mention earlier in this chapter, avoid using a GoTo statement unless it’s absolutely necessary. Using GoTo statements to perform looping</p>
<ul>
<li>Is contrary to the concept of structured programming. (See the sidebar earlier in this chapter, “What is structured programming? Does it matter?”)</li>
<li>Makes the code more difficult to read.</li>
<li>Is more prone to errors than using structured looping procedures.</li>
</ul>
<p style="text-align: justify;">VBA has enough structured looping commands that you almost never have to rely on GoTo statements for your decision making. Again, the exception is for error handling. Now you can move on to a discussion of good looping structures.</p>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/nested-for-next.html" title="Nested For-Next">Nested For-Next</a></li>
<li><a href="http://exceloptimize.com/vba/do-until-loop.html" title="Do-Until loop">Do-Until loop</a></li>
<li><a href="http://exceloptimize.com/vba/do-while-loop.html" title="Do-While loop">Do-While loop</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/looping-code.html&amp;Title=Looping+Code" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/looping-code.html&amp;title=Looping+Code" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/looping-code.html&amp;title=Looping+Code" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/looping-code.html&amp;title=Looping+Code" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/looping-code.html&amp;submitHeadline=Looping+Code&amp;submitSummary=The%20term%20looping%20refers%20to%20repeating%20a%20block%20of%20VBA%20statements%20numerous%20times.%20You%20may%20know%20how%20many%20times%20your%20program%20needs%20to%20loop%2C%20or%20variables%20used%20in%20your%20program%E2%80%99s%20code%20may%20determine%20this.%20There%20are%20two%20types%20of%20loops%3A%20good%20loops%20and%20bad%20loops.%20%28Good%20loops%20get%20rewarded%2C%20and%20bad%20loops%20get%20se&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/looping-code.html&amp;title=Looping+Code" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/looping-code.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/looping-code.html&amp;t=Looping+Code" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Looping+Code+-+http://b2l.me/bpq3g+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/looping-code.html&amp;bm_description=Looping+Code&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Looping+Code&amp;link=http://exceloptimize.com/vba/looping-code.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/looping-code.html&amp;type=Article&amp;title=Looping+Code" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/looping-code.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/looping-code.html&amp;n=Looping+Code&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/looping-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving Workbooks that Contain Macros</title>
		<link>http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html</link>
		<comments>http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html#comments</comments>
		<pubDate>Sun, 19 Apr 2009 18:41:58 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[saving workbooks]]></category>
		<category><![CDATA[vba contain]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/saving-workbooks-that-contain-macros.html</guid>
		<description><![CDATA[If you store one or more macros in a workbook, the file must be saved with “macros enabled.” In other words, the file must be saved with an XLSM extension rather than the normal XLSX extension.For example, if you try to save the workbook that contains your NameAndTime macro, the file format in the Save [...]]]></description>
			<content:encoded><![CDATA[<div align="justify">If you store one or more macros in a workbook, the file must be saved with “macros enabled.” In other words, the file must be saved with an XLSM extension rather than the normal XLSX extension.<br />For example, if you try to save the workbook that contains your NameAndTime macro, the file format in the Save As dialog box defaults to XLSX (a format that cannot contain macros!). Unless you change the file format to XLSM, Excel displays the warning shown in Figure 2-5. You need to click No, and then choose Excel Macro-Enabled Workbook (*.xlsm) from the Save As Type drop-down list.<br /><img style="max-width: 800px;" src="http://exceloptimize.com/wp-content/uploads/2009/04/2-5.jpg" width="413" height="115" /></div>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=b1c71df1-1327-82fe-ab46-921d8b1ae202" /></div>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/do-until-loop.html" title="Do-Until loop">Do-Until loop</a></li>
<li><a href="http://exceloptimize.com/vba/using-a-userform-as-a-progress-indicator.html" title="Using a UserForm as a progress indicator">Using a UserForm as a progress indicator</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;Title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;submitHeadline=Saving+Workbooks+that+Contain+Macros&amp;submitSummary=If%20you%20store%20one%20or%20more%20macros%20in%20a%20workbook%2C%20the%20file%20must%20be%20saved%20with%20%E2%80%9Cmacros%20enabled.%E2%80%9D%20In%20other%20words%2C%20the%20file%20must%20be%20saved%20with%20an%20XLSM%20extension%20rather%20than%20the%20normal%20XLSX%20extension.For%20example%2C%20if%20you%20try%20to%20save%20the%20workbook%20that%20contains%20your%20NameAndTime%20macro%2C%20the%20file%20format%20in%20t&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;t=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Saving+Workbooks+that+Contain+Macros+-+http://b2l.me/bpq3j+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;bm_description=Saving+Workbooks+that+Contain+Macros&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Saving+Workbooks+that+Contain+Macros&amp;link=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;type=Article&amp;title=Saving+Workbooks+that+Contain+Macros" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html&amp;n=Saving+Workbooks+that+Contain+Macros&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/saving-workbooks-that-contain-macros.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning off screen updating</title>
		<link>http://exceloptimize.com/vba/turning-off-screen-updating.html</link>
		<comments>http://exceloptimize.com/vba/turning-off-screen-updating.html#comments</comments>
		<pubDate>Sat, 21 Mar 2009 00:58:00 +0000</pubDate>
		<dc:creator>Andrian</dc:creator>
				<category><![CDATA[VBA Excel]]></category>
		<category><![CDATA[screen updating]]></category>
		<category><![CDATA[VBA code]]></category>

		<guid isPermaLink="false">http://exceloptimize.com/turning-off-screen-updating.html</guid>
		<description><![CDATA[When executing a macro, you can sit back and watch all the on-screen action that occurs in the macro. Although doing this can be instructive, after getting the macro working properly, it’s often annoying and can slow down the course of your macro considerably. Fortunately, you can disable the screen updating that normally occurs when [...]]]></description>
			<content:encoded><![CDATA[<div>When executing a macro, you can sit back and watch all the on-screen action that occurs in the macro. Although doing this can be instructive, after getting the macro working properly, it’s often annoying and can slow down the course of your macro considerably. Fortunately, you can disable the screen updating that normally occurs when you execute a macro. To turn off screen updating, use the following statement:<br />
Application.ScreenUpdating = False<br />
If you want the user to see what’s happening at any point during the macro, use the following statement to turn screen updating back on:<br />
Application.ScreenUpdating = True<br />
To demonstrate the difference in speed, execute this simple macro, which fills a range with numbers:</p>
<blockquote><p><span style="font-family: monospace;">Sub FillRange()<br />
Dim r as Long, c As Integer<br />
Dim Number as Long<br />
Number = 0<br />
For r = 1 To 50<br />
For c = 1 To 50<br />
Number = Number + 1<br />
Cells(r, c).Value = Number<br />
Next c<br />
Next r<br />
End Sub<br />
</span></p></blockquote>
<p>You see each value being entered into the cells. Now insert the following statement at the beginning of the procedure and execute it again:</p>
<blockquote><p><span style="font-family: monospace;">Application.ScreenUpdating = False<br />
</span></p></blockquote>
<p>The range is filled up much faster, and you don’t see the end result until the macro is finished running. When debugging code, sometimes program execution ends somewhere in the middle, without having turned Screen updating back on (and yes, this happens to me too). This sometimes causes Excel’s application window to become totally unresponsive. The way out of this frozen state is simple: Go back to the VBE and type the following statement in the Immediate window. Press the enter key to let the VBE execute this command.</p>
<blockquote><p><span style="font-family: monospace;">Application.ScreenUpdating = True</span></p></blockquote>
</div>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=942db550-1f1c-430d-b650-77fbd333fd32" alt="" /></div>
<h3>Related Post</h3>
<ul class="related_post">
<li><a href="http://exceloptimize.com/vba/for-next-with-a-step.html" title="For-Next with a Step">For-Next with a Step</a></li>
<li><a href="http://exceloptimize.com/vba/applying-chart-formatting.html" title="Applying chart formatting">Applying chart formatting</a></li>
<li><a href="http://exceloptimize.com/vba/modifying-chart-properties.html" title="Modifying chart properties">Modifying chart properties</a></li>
</ul>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;Title=Turning+off+screen+updating" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;title=Turning+off+screen+updating" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;title=Turning+off+screen+updating" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;title=Turning+off+screen+updating" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;submitHeadline=Turning+off+screen+updating&amp;submitSummary=When%20executing%20a%20macro%2C%20you%20can%20sit%20back%20and%20watch%20all%20the%20on-screen%20action%20that%20occurs%20in%20the%20macro.%20Although%20doing%20this%20can%20be%20instructive%2C%20after%20getting%20the%20macro%20working%20properly%2C%20it%E2%80%99s%20often%20annoying%20and%20can%20slow%20down%20the%20course%20of%20your%20macro%20considerably.%20Fortunately%2C%20you%20can%20disable%20the%20scre&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;title=Turning+off+screen+updating" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://exceloptimize.com/vba/turning-off-screen-updating.html" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?u=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;t=Turning+off+screen+updating" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Turning+off+screen+updating+-+http://b2l.me/bpsnd+" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;bm_description=Turning+off+screen+updating&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Turning+off+screen+updating&amp;link=http://exceloptimize.com/vba/turning-off-screen-updating.html" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-globalgrind">
			<a href="http://globalgrind.com/submission/submit.aspx?url=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;type=Article&amp;title=Turning+off+screen+updating" rel="nofollow" class="external" title="Grind this! on Global Grind">Grind this! on Global Grind</a>
		</li>
		<li class="sexy-squidoo">
			<a href="http://www.squidoo.com/lensmaster/bookmark?http://exceloptimize.com/vba/turning-off-screen-updating.html" rel="nofollow" class="external" title="Add to a lense on Squidoo">Add to a lense on Squidoo</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://exceloptimize.com/vba/turning-off-screen-updating.html&amp;n=Turning+off+screen+updating&amp;pli=1" rel="nofollow" class="external" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://exceloptimize.com/vba/turning-off-screen-updating.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
