VBA Insert formula with offset in cell and loop
<p>I've got hourly data. I need to have a cell that computes say the R<sup>2</sup> for days 1 and 7 between two different variables (say column A and B) and then loop this so next time it computes the R<sup>2</sup> for days 2-8 and then for days 3-9 etc etc.
I must say that the cell that has the R<sup>2</sup> formula is used in Solver to solve some code/formulas for max R<sup>2</sup>, so the cell that contains the R<sup>2</sup> needs to be a formula and not a value.. (I have been able to offset this as a value but not as a formula). Part of the current code is the following:</p>

<pre><code>i = 0
ActiveSheet.Cells(24,13).Value = Application.WorksheetFunction.RSq(RangeA.offset(i,0), RangeB.offset(i,0)

i = i + 24
</code></pre>

<p>Many many thanks in advance for any helpful tips</p>

<p>Cheers</p>