Excel set a range's value equal to a functionOk I'm pretty certain this should be really easy but I can't seem to figure it out or find any articles on it.<br><br>I would like to have a line of VBA code that will set the values a range of cells to a certain function.<br><br>Easy enough just<br><br>Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;).Value = &quot;=Row()&quot;<br><br>However what I want is to be able to include an If statement that references another cell in the same row so for example I want<br><br>B18=If(A18=&quot;&quot;,&quot;&quot;,Row())<br>B19=If(A19=&quot;&quot;,&quot;&quot;,Row())<br>B20=If(A20=&quot;&quot;,&quot;&quot;,Row()) <br>. . . <br><br>I know of two ways to do this but both run very slow I could put the formula somewhere and use VBA to copy and paste it or I could use a for each loop like this<br><br>For Each linerow In Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;)<br>      Sheets(&quot;Quote_Cover&quot;).Cells(linerow.Row, &quot;B&quot;) = &quot;=IF(A&quot; &amp; linerow.Row &amp; &quot;=&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;,Row())&quot;<br>Next linerow<br><br>But again both are extremely slow for this many cells so I would much rather have something of the form<br><br>Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;).Value = &quot;=IF(A&quot; &amp; Row() &amp; &quot;=&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;,Row())&quot;© 2009 Microsoft Corporation. All rights reserved.Wed, 04 Mar 2009 00:30:25 Z1339fa27-500a-4d32-b6b0-255d5c56261fhttp://social.msdn.microsoft.com/Forums/en/olsbgeneral/thread/1339fa27-500a-4d32-b6b0-255d5c56261f#1339fa27-500a-4d32-b6b0-255d5c56261fhttp://social.msdn.microsoft.com/Forums/en/olsbgeneral/thread/1339fa27-500a-4d32-b6b0-255d5c56261f#1339fa27-500a-4d32-b6b0-255d5c56261fmandalorian2http://social.msdn.microsoft.com/Profile/en-US/?user=mandalorian2Excel set a range's value equal to a functionOk I'm pretty certain this should be really easy but I can't seem to figure it out or find any articles on it.<br><br>I would like to have a line of VBA code that will set the values a range of cells to a certain function.<br><br>Easy enough just<br><br>Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;).Value = &quot;=Row()&quot;<br><br>However what I want is to be able to include an If statement that references another cell in the same row so for example I want<br><br>B18=If(A18=&quot;&quot;,&quot;&quot;,Row())<br>B19=If(A19=&quot;&quot;,&quot;&quot;,Row())<br>B20=If(A20=&quot;&quot;,&quot;&quot;,Row()) <br>. . . <br><br>I know of two ways to do this but both run very slow I could put the formula somewhere and use VBA to copy and paste it or I could use a for each loop like this<br><br>For Each linerow In Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;)<br>      Sheets(&quot;Quote_Cover&quot;).Cells(linerow.Row, &quot;B&quot;) = &quot;=IF(A&quot; &amp; linerow.Row &amp; &quot;=&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;,Row())&quot;<br>Next linerow<br><br>But again both are extremely slow for this many cells so I would much rather have something of the form<br><br>Sheets(&quot;Quote_Cover&quot;).Range(&quot;B18:B1000&quot;).Value = &quot;=IF(A&quot; &amp; Row() &amp; &quot;=&quot;&quot;&quot;&quot;,&quot;&quot;&quot;&quot;,Row())&quot;Wed, 04 Mar 2009 00:30:23 Z2009-03-04T00:30:23Z