<?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: Arrays Explained</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/</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: Bob Phillips</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36999</link>
		<dc:creator>Bob Phillips</dc:creator>
		<pubDate>Thu, 08 Jan 2009 22:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36999</guid>
		<description>&lt;p&gt;I set my arrays at some pre-deterimed size, and if I fill it, I double it. At the end I ReDim to the required size.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I set my arrays at some pre-deterimed size, and if I fill it, I double it. At the end I ReDim to the required size.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36985</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Thu, 08 Jan 2009 16:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36985</guid>
		<description>&lt;p&gt;I like having a definite upper bound, because often my arrays go back into the worksheet. Sometimes I&#039;ll run through a loop once to count how many rows my array will need, create the array, then populate it. I don&#039;t really know what the performance hit is, but usually in my apps, the time spent waiting for the user to scratch his head and click something is far far longer.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I like having a definite upper bound, because often my arrays go back into the worksheet. Sometimes I&#8217;ll run through a loop once to count how many rows my array will need, create the array, then populate it. I don&#8217;t really know what the performance hit is, but usually in my apps, the time spent waiting for the user to scratch his head and click something is far far longer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan Karel Pieterse</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36976</link>
		<dc:creator>Jan Karel Pieterse</dc:creator>
		<pubDate>Thu, 08 Jan 2009 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36976</guid>
		<description>&lt;p&gt;On some apps, fast *is* preferable over easy to read. Charles Williams and I enhanced the performance of our Name Manager quite a bit for workbooks with many range names (over a 100) and it helped to make the app usable in such situations.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>On some apps, fast *is* preferable over easy to read. Charles Williams and I enhanced the performance of our Name Manager quite a bit for workbooks with many range names (over a 100) and it helped to make the app usable in such situations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36964</link>
		<dc:creator>Jan</dc:creator>
		<pubDate>Wed, 07 Jan 2009 22:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36964</guid>
		<description>&lt;p&gt;Doubling sounds good, but perhaps we should consider +10% increments like SQL Server defaults to on its table space allocation growth.&lt;/p&gt;
&lt;p&gt;I am a combination of lazy and clean, so I prefer to increment by 1.  I think if you use Excel VBA, easy to read code is much better than fast but complex code.&lt;/p&gt;
&lt;p&gt;Also some functions require an Array of an exact size, for exampe the Sheets(Array(&quot;Sheet1?,&quot;Sheet2?)).select and if you had a huge array with empty gaps then the code would fail.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Doubling sounds good, but perhaps we should consider +10% increments like SQL Server defaults to on its table space allocation growth.</p>
<p>I am a combination of lazy and clean, so I prefer to increment by 1.  I think if you use Excel VBA, easy to read code is much better than fast but complex code.</p>
<p>Also some functions require an Array of an exact size, for exampe the Sheets(Array(&#8220;Sheet1?,&#8221;Sheet2?)).select and if you had a huge array with empty gaps then the code would fail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36925</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Wed, 07 Jan 2009 06:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36925</guid>
		<description>&lt;p&gt;First text in which I read about doubling array bound was Kernighan &amp; Pike&#039;s &#039;The Practice of Programming&#039;. I figure everyone else in Bell Labs was using this approach for years before it found its way into this book. And they probably took this from someone else back in the 1980s. Regardless, it ain&#039;t new.&lt;/p&gt;
&lt;p&gt;1D arrays are very useful. 2D arrays a little less so, thogh very handy for interfacing with ranges. Higher dimension arrays are usually much less useful compared to other structures in my experience.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>First text in which I read about doubling array bound was Kernighan &amp; Pike&#8217;s &#8216;The Practice of Programming&#8217;. I figure everyone else in Bell Labs was using this approach for years before it found its way into this book. And they probably took this from someone else back in the 1980s. Regardless, it ain&#8217;t new.</p>
<p>1D arrays are very useful. 2D arrays a little less so, thogh very handy for interfacing with ranges. Higher dimension arrays are usually much less useful compared to other structures in my experience.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36916</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Wed, 07 Jan 2009 01:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36916</guid>
		<description>&lt;p&gt;Doug -&lt;/p&gt;
&lt;p&gt;For a text file that has rows separated by CR or LF, you could read the entire file into a string, then use Split to construct your array.&lt;/p&gt;
&lt;p&gt;Depending on the application, I have sometimes first converted CSV files into an array of rows by splitting at the CR/LF, then converted each row into an array by splitting at the tab character. You reference the elements using Array(i)(j) instead of Array(i,j), but I guess that&#039;s about the only difference.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Doug -</p>
<p>For a text file that has rows separated by CR or LF, you could read the entire file into a string, then use Split to construct your array.</p>
<p>Depending on the application, I have sometimes first converted CSV files into an array of rows by splitting at the CR/LF, then converted each row into an array by splitting at the tab character. You reference the elements using Array(i)(j) instead of Array(i,j), but I guess that&#8217;s about the only difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36910</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Tue, 06 Jan 2009 23:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36910</guid>
		<description>&lt;p&gt;I too am a big fan of arrays, and I don&#039;t care at all if they are &quot;obsolete&quot;.  Since worksheet ranges are in effect 2D arrays it makes sense to me to use them in VBA.  The ease with which data is passed from a worksheet range to a VBA variant is an added bonus, and the fact that much engineering analysis involves working with matrices (which is just another name for arrays) makes them the obvious choice.&lt;/p&gt;
&lt;p&gt;In nearly all cases I will know (or be able to calculate) the array size, based on the size of the range/array passed from the spreadsheet, so there will only be a need for at most one re-dim at the start.  The only one of my applications I can think of immediately where this doesn&#039;t apply are functions/subs for reading text files.  In this case I step through the file first to count the number of rows, then redim an array, then read each line into the array.  That sounds hopelessly inefficient, but in practice it adds hardly anything to the execution time.  An alternative would be to just dimension the array to the maximum number of rows in a spreadsheet.&lt;/p&gt;
&lt;p&gt;I tend to use arrays with named ranges, then to write the entire contents of an array to a named range:&lt;/p&gt;
&lt;p&gt;With Range(&quot;MyNamedRange&quot;)&lt;br&gt;
.Resize(NumArrayRows, NumArrayColumns).Name = &quot;MyNamedRange&quot;&lt;br&gt;
.Value = MyArray&lt;br&gt;
End With&lt;/p&gt;
&lt;p&gt;This works virtually instantaneously, even with huge ranges.  The improvement in performance compared with writing cell by cell is likely to be a factor of tens or hundreds (or compared with cell by cell writing with auto-recalc still enabled, thousands).&lt;/p&gt;
&lt;p&gt;More here: &lt;a href=&quot;http://newtonexcelbach.wordpress.com/2008/03/05/ranges-and-arrays-2/&quot; rel=&quot;nofollow&quot;&gt;http://newtonexcelbach.wordpress.com/2008/03/05/ranges-and-arrays-2/&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I too am a big fan of arrays, and I don&#8217;t care at all if they are &#8220;obsolete&#8221;.  Since worksheet ranges are in effect 2D arrays it makes sense to me to use them in VBA.  The ease with which data is passed from a worksheet range to a VBA variant is an added bonus, and the fact that much engineering analysis involves working with matrices (which is just another name for arrays) makes them the obvious choice.</p>
<p>In nearly all cases I will know (or be able to calculate) the array size, based on the size of the range/array passed from the spreadsheet, so there will only be a need for at most one re-dim at the start.  The only one of my applications I can think of immediately where this doesn&#8217;t apply are functions/subs for reading text files.  In this case I step through the file first to count the number of rows, then redim an array, then read each line into the array.  That sounds hopelessly inefficient, but in practice it adds hardly anything to the execution time.  An alternative would be to just dimension the array to the maximum number of rows in a spreadsheet.</p>
<p>I tend to use arrays with named ranges, then to write the entire contents of an array to a named range:</p>
<p>With Range(&#8220;MyNamedRange&#8221;)<br />
.Resize(NumArrayRows, NumArrayColumns).Name = &#8220;MyNamedRange&#8221;<br />
.Value = MyArray<br />
End With</p>
<p>This works virtually instantaneously, even with huge ranges.  The improvement in performance compared with writing cell by cell is likely to be a factor of tens or hundreds (or compared with cell by cell writing with auto-recalc still enabled, thousands).</p>
<p>More here: <a href="http://newtonexcelbach.wordpress.com/2008/03/05/ranges-and-arrays-2/" rel="nofollow">http://newtonexcelbach.wordpress.com/2008/03/05/ranges-and-arrays-2/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Williams</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36907</link>
		<dc:creator>Charles Williams</dc:creator>
		<pubDate>Tue, 06 Jan 2009 21:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36907</guid>
		<description>&lt;p&gt;When you read a range into a variant you don&#039;t need to redim it anyway, and this is much the most efficient way of transferring data from Excel to VBA. For example -&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;Dim&lt;/span&gt; vArr &lt;span class=&quot;kw1&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;variant&lt;/span&gt;&lt;br&gt;
vArr=Range(&lt;span class=&quot;st0&quot;&gt;&quot;A1&quot;&lt;/span&gt;).resize(Range(&lt;span class=&quot;st0&quot;&gt;&quot;A65536&quot;&lt;/span&gt;).&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;(xlup).row,2)&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Otherwise I either Dim the Array to the max possible size or double it.&lt;/p&gt;
&lt;p&gt;Usually its not worth bothering to do a final Redim Preserve to shrink the array unless you are assigning the array back to a Range.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>When you read a range into a variant you don&#8217;t need to redim it anyway, and this is much the most efficient way of transferring data from Excel to VBA. For example -</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Dim</span> vArr <span class="kw1">as</span> <span class="kw1">variant</span><br />
vArr=Range(<span class="st0">&#8220;A1&#8243;</span>).resize(Range(<span class="st0">&#8220;A65536&#8243;</span>).<span class="kw1">end</span>(xlup).row,2)</div>
</div>
<p>Otherwise I either Dim the Array to the max possible size or double it.</p>
<p>Usually its not worth bothering to do a final Redim Preserve to shrink the array unless you are assigning the array back to a Range.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36906</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Tue, 06 Jan 2009 20:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36906</guid>
		<description>&lt;p&gt;Mathias:  Escape any less-than signs in your code or it will get cut off.&lt;/p&gt;
&lt;p&gt;Jon:  Because I&#039;m just doing the array work inside the class, so why not just do it where I need it.  OK, there are good reasons for having it in the class, but it only moves the implementation questions.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Mathias:  Escape any less-than signs in your code or it will get cut off.</p>
<p>Jon:  Because I&#8217;m just doing the array work inside the class, so why not just do it where I need it.  OK, there are good reasons for having it in the class, but it only moves the implementation questions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/06/arrays-explained/#comment-36904</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Tue, 06 Jan 2009 20:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1935#comment-36904</guid>
		<description>&lt;p&gt;Dick -&lt;/p&gt;
&lt;p&gt;If you built a SmartArray class, why wouldn&#039;t you include methods to populate the array from a range, or dump the array&#039;s contents into a range?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dick -</p>
<p>If you built a SmartArray class, why wouldn&#8217;t you include methods to populate the array from a range, or dump the array&#8217;s contents into a range?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

