<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Efficient Looping</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32135</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Thu, 01 May 2008 04:30:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32135</guid>
		<description>&lt;p&gt;Tushar -&lt;/p&gt;
&lt;p&gt;Nice analysis.&lt;/p&gt;
&lt;p&gt;(1) I did in fact notice this, and thought about loading column 2 into a second array, so that any blanks in my output array did not overwrite any values in that column, but it was getting late....&lt;/p&gt;
&lt;p&gt;(2) Not true. I can test the element of the array, then bold the corresponding cell in the sheet. This still minimizes interaction with the worksheet (though of course reading a value is much faster than changing a format).&lt;/p&gt;
&lt;p&gt;(3) I assumed this, and was going to run a nice model to demonstrate, but the data didn&#039;t show the nice behavior I&#039;d expected.&lt;/p&gt;
&lt;p&gt;(4) Interface matters. I don&#039;t kill myself optimizing a two second routine if the user spends five minutes thinking about what the analysis means.&lt;/p&gt;
&lt;p&gt;(5) I like this approach, depending on what the &quot;do something&quot; means. If you put a formula in place that is based on column 1, it updates from that point on without rerunning the code.&lt;/p&gt;
&lt;p&gt;(7) &quot;Optimization is rarely as easy as people make it out to be.&quot; Yes sir. To me, optimization is about making something modular so I can reuse it with little fuss, and making it self-documenting so I can remember how it works quickly. The whole array thing works for me as for you, because I have a set of library routines that process arrays, and supporting routines that do range-array and csv-array and similar translations. Optimization for my projects is more about streamlining development processes rather than code execution processes.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Tushar -</p>
<p>Nice analysis.</p>
<p>(1) I did in fact notice this, and thought about loading column 2 into a second array, so that any blanks in my output array did not overwrite any values in that column, but it was getting late&#8230;.</p>
<p>(2) Not true. I can test the element of the array, then bold the corresponding cell in the sheet. This still minimizes interaction with the worksheet (though of course reading a value is much faster than changing a format).</p>
<p>(3) I assumed this, and was going to run a nice model to demonstrate, but the data didn&#8217;t show the nice behavior I&#8217;d expected.</p>
<p>(4) Interface matters. I don&#8217;t kill myself optimizing a two second routine if the user spends five minutes thinking about what the analysis means.</p>
<p>(5) I like this approach, depending on what the &#8220;do something&#8221; means. If you put a formula in place that is based on column 1, it updates from that point on without rerunning the code.</p>
<p>(7) &#8220;Optimization is rarely as easy as people make it out to be.&#8221; Yes sir. To me, optimization is about making something modular so I can reuse it with little fuss, and making it self-documenting so I can remember how it works quickly. The whole array thing works for me as for you, because I have a set of library routines that process arrays, and supporting routines that do range-array and csv-array and similar translations. Optimization for my projects is more about streamlining development processes rather than code execution processes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32133</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Thu, 01 May 2008 03:38:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32133</guid>
		<description>&lt;p&gt;Wow, I just realized why I started reading this blog... for the high value posting! Dick it looks like you beat me to it with your own test that shows the loop speed. Thanks as well to Jon, Charles and Tushar for the excellent info, I might actually have to print this thread out and spend some time digesting.&lt;/p&gt;
&lt;p&gt;Thx,&lt;br&gt;
JP&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wow, I just realized why I started reading this blog&#8230; for the high value posting! Dick it looks like you beat me to it with your own test that shows the loop speed. Thanks as well to Jon, Charles and Tushar for the excellent info, I might actually have to print this thread out and spend some time digesting.</p>
<p>Thx,<br />
JP</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32131</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Wed, 30 Apr 2008 22:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32131</guid>
		<description>&lt;p&gt;Six comments.  But first, don&#039;t get me wrong.  I often use the variant=range.value (and reverse) in my code.  It almost always improves performance.  However, as I mentioned in the other discussion, most of the time the primary motivation is flexibility.&lt;/p&gt;
&lt;p&gt;(1) Since Dick did not output the result of his &quot;do something,&quot; he missed something that Jon ought to have caught with his version of the code.  The code using the variant=range.value and range.value=variant is *not* functionally identical to the one that loops through the cells one at a time!  The variant version replaces all the cells in the output column whereas the cell-at-a-time code only updates those cells where the If test yields True!&lt;/p&gt;
&lt;p&gt;(2) The var=range.value method works only if we want to work with data and not with the Excel object.  So, if Dick wanted to change the font color or the background color or, as Andy did, bold the cells, this method would not work.&lt;/p&gt;
&lt;p&gt;(3) Optimizations are not always data-independent.  I created 2 data sets.  The first consisted of 65536 cells in column A with the formula =IF(MOD(ROW(),100)=0,&quot;abc&quot;&amp;ROW(),&quot;Total&quot;&amp;ROW()).  This yields a lot of cells starting with &quot;Total&quot;.  I also created the &quot;inverse&quot; set with the formula =IF(MOD(ROW(),100)&lt;&gt;0,&quot;abc&quot;&amp;ROW(),&quot;Total&quot;&amp;ROW())  This of course, had only 1 out of every 100 rows starting with &quot;Total&quot;&lt;/p&gt;
&lt;p&gt;I also reported the results not just in total time but also on a &quot;per-cell&quot; basis.  My results were&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&#160;47.20703 &#160; &#160; &#160;7.20322132110596E-04 &lt;br&gt;
&#160;0.203125 &#160; &#160; &#160;3.09944152832031E-06 &lt;br&gt;
&lt;br&gt;
&#160;0.78125 &#160; &#160; &#160; 1.19209289550781E-05 &lt;br&gt;
&#160;0.125 &#160; &#160; &#160; &#160; 1.9073486328125E-06&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;So, while the variant=range.value code is always faster than the cell-at-a-time code, the benefit varies based on the data set.&lt;/p&gt;
&lt;p&gt;(4) All the different samples relied on testing just the interface without accounting for what the core &quot;do something&quot; code does.  Let&#039;s use the above numbers to establish a baseline.  If the core &quot;do something&quot; code runs much faster than 1.2E-5 to 7.2E-4 seconds, the interface does matter!  However, the longer that the core code takes, the less the interface matters.&lt;/p&gt;
&lt;p&gt;Some time ago, I was asked by a client to improve the performance of some code.  It used several PivotTables to analyze the raw data and then extracted and organized the data from the resulting PivotTables into tables and charts that the client wanted.  The client told me their IT group was overloaded and couldn&#039;t work on the problem but the IT person was certain the problem was with the tables and charts that were being created.&lt;/p&gt;
&lt;p&gt;The first thing I did was add a bunch of timing code to find where the problem was.  It turned out the original code created a PT, used the data from the first row, and then &#039;hid&#039; that PT element.  The last part, i.e., hiding the element, could, under certain circumstances, take a long time.  So, I rewrote the code to simply step through each row of the PT and performance improved by a magnitude!&lt;/p&gt;
&lt;p&gt;Contrary to the IT expert, the performance problem had nothing to do with the number of charts or updating the charts or whatever.&lt;/p&gt;
&lt;p&gt;My point about the story is preemptive (and premature) decisions about optimization may often be nothing but a waste of time.&lt;/p&gt;
&lt;p&gt;(5) Using other algorithms: Data independent performance.  Can we make our code performance independent of data?  Given that we are dealing with Excel, yes, within limits.  If we want to add something in an adjacent column (as Jon did in his example), we can use&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; useFormula(Rng &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Range)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt; Rng.Offset(0, 1)&lt;br&gt;
&#160; &#160; .FormulaR1C1 = _&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;st0&quot;&gt;&quot;=IF(LEFT(RC[-1],LEN(&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Total&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;))=&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Total&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;okay&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;)&quot;&lt;/span&gt;&lt;br&gt;
&#160; &#160; .Value = .Value&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We could also add conditional formatting, etc., though we would have a hard time working with the entire row.&lt;/p&gt;
&lt;p&gt;How well does the above code perform?  With only a few cells starting with &quot;Total&quot;, it took 0.25 seconds and with lots of cells starting with &quot;Total&quot;, it took 0.27 seconds.  Clearly, it is almost totally data-independent.  Not to mention it is easy to write, understand, and maintain!  And, as a bonus, it is very fast!&lt;/p&gt;
&lt;p&gt;(6) Using other algorithms: Convenience.  How about an algorithm that provides programming convenience?  I used the FindAll method I wrote some time ago (http://www.tushar-mehta.com/excel/tips/findall.html)&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; useFindAll(Rng &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Range)&lt;br&gt;
&#160; &#160; FindAll(&lt;span class=&quot;st0&quot;&gt;&quot;Total*&quot;&lt;/span&gt;, Rng, LookIn:=xlValues, LookAt:=xlWhole).Offset(0, 4).Value = &lt;span class=&quot;st0&quot;&gt;&quot;okay&quot;&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that this is the first algorithm that does exactly what the original code did.  It only updates those cells where the adjacent cell starts with &quot;Total.&quot;  So, in that sense this is the only truly comparable method!  It also retains the ability to work with the Excel object.&lt;/p&gt;
&lt;p&gt;How well does it perform.  Well, with a lot of cells starting with &quot;Total&quot; it took about 56 seconds and with a few cells it took about 0.6 seconds.  So, it is faster than the cell-by-cell method by just under 25%.&lt;/p&gt;
&lt;p&gt;Summary: Optimization is rarely as easy as people make it out to be.  Most people focus on micro-optimizations that are rarely truly beneficial.  Optimizations can also be such that they don&#039;t truly duplicate the functionality of the original code.  Finally, optimizing without understanding the true nature of the bottleneck doesn&#039;t always yield the expected benefits, not to mention that it may take away some of the flexibility embedded in the original code.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Six comments.  But first, don&#8217;t get me wrong.  I often use the variant=range.value (and reverse) in my code.  It almost always improves performance.  However, as I mentioned in the other discussion, most of the time the primary motivation is flexibility.</p>
<p>(1) Since Dick did not output the result of his &#8220;do something,&#8221; he missed something that Jon ought to have caught with his version of the code.  The code using the variant=range.value and range.value=variant is *not* functionally identical to the one that loops through the cells one at a time!  The variant version replaces all the cells in the output column whereas the cell-at-a-time code only updates those cells where the If test yields True!</p>
<p>(2) The var=range.value method works only if we want to work with data and not with the Excel object.  So, if Dick wanted to change the font color or the background color or, as Andy did, bold the cells, this method would not work.</p>
<p>(3) Optimizations are not always data-independent.  I created 2 data sets.  The first consisted of 65536 cells in column A with the formula =IF(MOD(ROW(),100)=0,&#8221;abc&#8221;&amp;ROW(),&#8221;Total&#8221;&amp;ROW()).  This yields a lot of cells starting with &#8220;Total&#8221;.  I also created the &#8220;inverse&#8221; set with the formula =IF(MOD(ROW(),100)&lt;&gt;0,&#8221;abc&#8221;&amp;ROW(),&#8221;Total&#8221;&amp;ROW())  This of course, had only 1 out of every 100 rows starting with &#8220;Total&#8221;</p>
<p>I also reported the results not just in total time but also on a &#8220;per-cell&#8221; basis.  My results were</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer">&nbsp;47.20703 &nbsp; &nbsp; &nbsp;7.20322132110596E-04 <br />
&nbsp;0.203125 &nbsp; &nbsp; &nbsp;3.09944152832031E-06 </p>
<p>&nbsp;0.78125 &nbsp; &nbsp; &nbsp; 1.19209289550781E-05 <br />
&nbsp;0.125 &nbsp; &nbsp; &nbsp; &nbsp; 1.9073486328125E-06</div>
</div>
<p>So, while the variant=range.value code is always faster than the cell-at-a-time code, the benefit varies based on the data set.</p>
<p>(4) All the different samples relied on testing just the interface without accounting for what the core &#8220;do something&#8221; code does.  Let&#8217;s use the above numbers to establish a baseline.  If the core &#8220;do something&#8221; code runs much faster than 1.2E-5 to 7.2E-4 seconds, the interface does matter!  However, the longer that the core code takes, the less the interface matters.</p>
<p>Some time ago, I was asked by a client to improve the performance of some code.  It used several PivotTables to analyze the raw data and then extracted and organized the data from the resulting PivotTables into tables and charts that the client wanted.  The client told me their IT group was overloaded and couldn&#8217;t work on the problem but the IT person was certain the problem was with the tables and charts that were being created.</p>
<p>The first thing I did was add a bunch of timing code to find where the problem was.  It turned out the original code created a PT, used the data from the first row, and then &#8216;hid&#8217; that PT element.  The last part, i.e., hiding the element, could, under certain circumstances, take a long time.  So, I rewrote the code to simply step through each row of the PT and performance improved by a magnitude!</p>
<p>Contrary to the IT expert, the performance problem had nothing to do with the number of charts or updating the charts or whatever.</p>
<p>My point about the story is preemptive (and premature) decisions about optimization may often be nothing but a waste of time.</p>
<p>(5) Using other algorithms: Data independent performance.  Can we make our code performance independent of data?  Given that we are dealing with Excel, yes, within limits.  If we want to add something in an adjacent column (as Jon did in his example), we can use</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Sub</span> useFormula(Rng <span class="kw1">As</span> Range)<br />
&nbsp; &nbsp; <span class="kw1">With</span> Rng.Offset(0, 1)<br />
&nbsp; &nbsp; .FormulaR1C1 = _<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8220;=IF(LEFT(RC[-1],LEN(&#8220;</span><span class="st0">&#8220;Total&#8221;</span><span class="st0">&#8220;))=&#8221;</span><span class="st0">&#8220;Total&#8221;</span><span class="st0">&#8220;,&#8221;</span><span class="st0">&#8220;okay&#8221;</span><span class="st0">&#8220;,&#8221;</span><span class="st0">&#8220;&#8221;</span><span class="st0">&#8220;)&#8221;</span><br />
&nbsp; &nbsp; .Value = .Value<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">With</span><br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
<p>We could also add conditional formatting, etc., though we would have a hard time working with the entire row.</p>
<p>How well does the above code perform?  With only a few cells starting with &#8220;Total&#8221;, it took 0.25 seconds and with lots of cells starting with &#8220;Total&#8221;, it took 0.27 seconds.  Clearly, it is almost totally data-independent.  Not to mention it is easy to write, understand, and maintain!  And, as a bonus, it is very fast!</p>
<p>(6) Using other algorithms: Convenience.  How about an algorithm that provides programming convenience?  I used the FindAll method I wrote some time ago (<a href="http://www.tushar-mehta.com/excel/tips/findall.html" rel="nofollow">http://www.tushar-mehta.com/excel/tips/findall.html</a>)</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Sub</span> useFindAll(Rng <span class="kw1">As</span> Range)<br />
&nbsp; &nbsp; FindAll(<span class="st0">&#8220;Total*&#8221;</span>, Rng, LookIn:=xlValues, LookAt:=xlWhole).Offset(0, 4).Value = <span class="st0">&#8220;okay&#8221;</span><br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">Sub</span></div>
</div>
<p>Note that this is the first algorithm that does exactly what the original code did.  It only updates those cells where the adjacent cell starts with &#8220;Total.&#8221;  So, in that sense this is the only truly comparable method!  It also retains the ability to work with the Excel object.</p>
<p>How well does it perform.  Well, with a lot of cells starting with &#8220;Total&#8221; it took about 56 seconds and with a few cells it took about 0.6 seconds.  So, it is faster than the cell-by-cell method by just under 25%.</p>
<p>Summary: Optimization is rarely as easy as people make it out to be.  Most people focus on micro-optimizations that are rarely truly beneficial.  Optimizations can also be such that they don&#8217;t truly duplicate the functionality of the original code.  Finally, optimizing without understanding the true nature of the bottleneck doesn&#8217;t always yield the expected benefits, not to mention that it may take away some of the flexibility embedded in the original code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Williams</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32127</link>
		<dc:creator>Charles Williams</dc:creator>
		<pubDate>Wed, 30 Apr 2008 20:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32127</guid>
		<description>&lt;p&gt;Michael,&lt;/p&gt;
&lt;p&gt;You are absolutely correct,&lt;br&gt;
apologies to fzz ...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael,</p>
<p>You are absolutely correct,<br />
apologies to fzz &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32124</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Wed, 30 Apr 2008 19:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32124</guid>
		<description>&lt;p&gt;Charles -&lt;/p&gt;
&lt;p&gt;As fzz wrote&lt;/p&gt;
&lt;p&gt;&quot;If InStr(1, c.Text, s2m) = 1 Then&quot;&lt;/p&gt;
&lt;p&gt;Only checks passes for &quot;Total&quot; at the left.  I too tend to use&lt;/p&gt;
&lt;p&gt;If InStr() Then&lt;/p&gt;
&lt;p&gt;but fzz was more specific.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Charles -</p>
<p>As fzz wrote</p>
<p>&#8220;If InStr(1, c.Text, s2m) = 1 Then&#8221;</p>
<p>Only checks passes for &#8220;Total&#8221; at the left.  I too tend to use</p>
<p>If InStr() Then</p>
<p>but fzz was more specific.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Williams</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32121</link>
		<dc:creator>Charles Williams</dc:creator>
		<pubDate>Wed, 30 Apr 2008 18:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32121</guid>
		<description>&lt;p&gt;Using .Find is very sensitive to the number of hits: so with Dick&#039;s (extreme) test case .find is by far the slowest, but if you invert the test (so you are looking for 10 hits out of 65000) it becomes the fastest.&lt;/p&gt;
&lt;p&gt;Some minor quibbles with other solutions:&lt;/p&gt;
&lt;p&gt;- I almost never use .Text because it can return #### if the column size is too small or the user may have changed the formatting(and .Text can do funny things in UDFs)&lt;br&gt;
- If Left$(vArr(i, 1), Len(sFIND)) = sFIND Then does not work if any of the text is shorter than sFind&lt;br&gt;
- Using Instr does not necessarily give the same solution as Left or Like Total* because it will also find SubTotal for example&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Using .Find is very sensitive to the number of hits: so with Dick&#8217;s (extreme) test case .find is by far the slowest, but if you invert the test (so you are looking for 10 hits out of 65000) it becomes the fastest.</p>
<p>Some minor quibbles with other solutions:</p>
<p>- I almost never use .Text because it can return #### if the column size is too small or the user may have changed the formatting(and .Text can do funny things in UDFs)<br />
- If Left$(vArr(i, 1), Len(sFIND)) = sFIND Then does not work if any of the text is shorter than sFind<br />
- Using Instr does not necessarily give the same solution as Left or Like Total* because it will also find SubTotal for example</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32117</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Wed, 30 Apr 2008 15:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32117</guid>
		<description>&lt;p&gt;For some reason I thought Timer was a Long.  I guess all those decimal places should have tipped me off.  Help says it&#039;s a Single, so you guys are right.  Also, moving the Len outside the loop is good tip, so thanks Nicholas.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>For some reason I thought Timer was a Long.  I guess all those decimal places should have tipped me off.  Help says it&#8217;s a Single, so you guys are right.  Also, moving the Len outside the loop is good tip, so thanks Nicholas.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Bullen</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32115</link>
		<dc:creator>Stephen Bullen</dc:creator>
		<pubDate>Wed, 30 Apr 2008 13:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32115</guid>
		<description>&lt;p&gt;Just a small quibble, but when I ran the code, I got the second one taking negative time! All because your lStart is defined as a Long, so the Timer gets rounded to the nearest integer. It should be a Double.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Just a small quibble, but when I ran the code, I got the second one taking negative time! All because your lStart is defined as a Long, so the Timer gets rounded to the nearest integer. It should be a Double.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32112</link>
		<dc:creator>Ross</dc:creator>
		<pubDate>Wed, 30 Apr 2008 09:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32112</guid>
		<description>&lt;p&gt;Bit off topic but, I was working with some large size arrays recently and kept getting a memory error. This only happened when I returned strings, to a variant, it was ok with ints.&lt;br&gt;
I think (can&#039;t quite remember now!) i re-typed the array to a string and it worked ok with strings. But it was not something I was expecting. &lt;/p&gt;
&lt;p&gt;(yes, I had a reason for using a variant in the first place(I hope!))&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Bit off topic but, I was working with some large size arrays recently and kept getting a memory error. This only happened when I returned strings, to a variant, it was ok with ints.<br />
I think (can&#8217;t quite remember now!) i re-typed the array to a string and it worked ok with strings. But it was not something I was expecting. </p>
<p>(yes, I had a reason for using a variant in the first place(I hope!))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/04/29/efficient-looping/#comment-32110</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Wed, 30 Apr 2008 06:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1835#comment-32110</guid>
		<description>&lt;p&gt;To do this test I filled column A with text, to see if that made any difference.  It didn&#039;t, but in XL2007 when I try to erase the text or delete the rows it locks up, and I have to close Excel down with Task Manager.&lt;/p&gt;
&lt;p&gt;Does anyone else get that?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>To do this test I filled column A with text, to see if that made any difference.  It didn&#8217;t, but in XL2007 when I try to erase the text or delete the rows it locks up, and I have to close Excel down with Task Manager.</p>
<p>Does anyone else get that?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

