Runtime Error 1004 Copy Formula Array
<p>I have the following array formula in cell B2 in my Excel spreadsheet:</p>

<pre><code>{=IF(COUNT(IF(ISNUMBER(A30:A1000);IF(B30:B1000&gt;A30:A1000-1;A30:A1000)))&gt;=COUNT(IF(ISNUMBER(A30:A1000);COUNT(B30:B1000&gt;A30:A1000-1;A30:A1000)));COUNT(IF(ISNUMBER(A30:A1000);COUNT(B30:B1000&gt;A30:A1000-1;A30:A1000))))}
</code></pre>

<p>Now I want to use the following VBA code to copy this code into cell A2:</p>

<pre><code>Sheets("Sheet1").Range("A2").FormulaArray = Sheets("Sheet1").Range("B2").Formula
</code></pre>

<p>However, when I use this code I get runtime error 1004.</p>

<p>Do you have any idea how to solve this issue?</p>