Microsoft KB Archive/51843

{| = Excel: Increasing Efficiency in Looping Over a Region of Cells =
 * width="100%"|

Last reviewed: April 3, 1997

Article ID: Q51843 2.20 MACINTOSH kbother The information in this article applies to:


 * Microsoft Excel for the Macintosh, version 2.2

SUMMARY
In Microsoft Excel, when you need to loop over a region of cells (such as to perform some repetitive operation), use the OFFSET or INDEX command instead of concatenating a reference string.

The typical macro written to loop over a region of cells may look like the following:

=FOR(&quot;i&quot;,1,10) =FORMULA(&quot;10&quot;,&quot;TEST.XLS!R&quot;&i&&quot;C1&quot;) =NEXT The above macro can be replaced by the faster version shown below: =FOR(&quot;i&quot;,0,9) =FORMULA(&quot;10&quot;,OFFSET(TEST.XLS!R1C1,i,0)) =NEXT

MORE INFORMATION
This information was taken from page 153 of the &quot;Microsoft Excel Technical Reference for the Macintosh,&quot; which can be obtained by calling Microsoft End User Sales and Service at (800) 426-9400.

Note: Page 153 displays an incorrect example of the loops because it does not include the parentheses after the NEXT statement.
 * }