<?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: VBA Function: Populating a Range</title>
	<atom:link href="http://www.automateexcel.com/2008/09/26/vba-function-populating-a-range/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.automateexcel.com/2008/09/26/vba-function-populating-a-range/</link>
	<description>Everything Excel. Only Excel.</description>
	<lastBuildDate>Mon, 21 Nov 2011 07:25:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: SuperT</title>
		<link>http://www.automateexcel.com/2008/09/26/vba-function-populating-a-range/comment-page-1/#comment-1178</link>
		<dc:creator>SuperT</dc:creator>
		<pubDate>Mon, 30 Mar 2009 23:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.automateexcel.com/?p=918#comment-1178</guid>
		<description>Excel throws a &quot;Application-defined or object-defined error&quot; when the length of the string in any of the array&#039;s element is &gt; 911 characters.</description>
		<content:encoded><![CDATA[<p>Excel throws a &#8220;Application-defined or object-defined error&#8221; when the length of the string in any of the array&#8217;s element is &gt; 911 characters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.automateexcel.com/2008/09/26/vba-function-populating-a-range/comment-page-1/#comment-884</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 26 Sep 2008 18:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.automateexcel.com/?p=918#comment-884</guid>
		<description>This is around 10 times faster. Define an array the size of Cell_Range, populate the array with random numbers, and populate Cell_Range with the array. By only writing to the worksheet once for the whole routine, instead of once per cell, yoou can save lots of time.

Sub Randomise_Range2(Cell_Range As Range)
&#039; Will randomise each cell in Range
Dim v
Dim i As Long
Dim j As Long
&#039;Turn off screen alerts
Application.ScreenUpdating = False
ReDim v(1 To Cell_Range.Rows.Count, 1 To Cell_Range.Columns.Count)
For i = 1 To Cell_Range.Rows.Count
For j = 1 To Cell_Range.Columns.Count
v(i, j) = Rnd * 1000
Next j
Next i
Cell_Range.Value = v
Application.ScreenUpdating = True
End Sub

Your code took 0.46 to 0.68 seconds to populate A1:A5000 (in five trials), my code took 0.031 to 0.078 seconds.</description>
		<content:encoded><![CDATA[<p>This is around 10 times faster. Define an array the size of Cell_Range, populate the array with random numbers, and populate Cell_Range with the array. By only writing to the worksheet once for the whole routine, instead of once per cell, yoou can save lots of time.</p>
<p>Sub Randomise_Range2(Cell_Range As Range)<br />
&#8216; Will randomise each cell in Range<br />
Dim v<br />
Dim i As Long<br />
Dim j As Long<br />
&#8216;Turn off screen alerts<br />
Application.ScreenUpdating = False<br />
ReDim v(1 To Cell_Range.Rows.Count, 1 To Cell_Range.Columns.Count)<br />
For i = 1 To Cell_Range.Rows.Count<br />
For j = 1 To Cell_Range.Columns.Count<br />
v(i, j) = Rnd * 1000<br />
Next j<br />
Next i<br />
Cell_Range.Value = v<br />
Application.ScreenUpdating = True<br />
End Sub</p>
<p>Your code took 0.46 to 0.68 seconds to populate A1:A5000 (in five trials), my code took 0.031 to 0.078 seconds.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

