VBA Run time error 1004: Unable to set the formulaarray property of the range class
<p>VBA Run time error 1004: Unable to set the formulaarray property of the range class</p>

<p>I've followed Dick Kusleika's advice in this <a href="http://dailydoseofexcel.com/archives/2005/01/10/entering-long-array-formulas-in-vba/" rel="nofollow noreferrer">link</a>, but can't get the following array formula to enter into excel via VBA. Can anyone see where I'm going wrong? Both halves of the formula are easily below 255 characters.</p>

<pre><code>Public Sub Configuration()

Dim theFormulaPart1 As String

Dim theFormulaPart2 As String

theFormulaPart1 = "=IF(ISODD(B2),IFERROR(INDEX(Race1Grid,MATCH(C2&amp;I2&amp;""Q3""," &amp; _
                "QualRace1ID&amp;QualDriver&amp;QSession,0)),IFERROR(INDEX(Race1Grid" &amp; _
                ",MATCH(C2&amp;I2&amp;""Q2"",QualRace1ID&amp;QualDriver&amp;QSession,0)),INDEX" &amp; _
                "(Race1Grid,MATCH(C2&amp;I2,QualRace1ID&amp;QualDriver,0))))," &amp; _
                "X_X_X())"

theFormulaPart2 = "IFERROR(INDEX(Race2Grid,MATCH(C2&amp;I2&amp;""Q3"",QualRace2ID&amp;" &amp; _
                "QualDriver&amp;QSession,0)),IFERROR(INDEX(Race2Grid,MATCH(C2&amp;" &amp; _
                "I2&amp;""Q2"",QualRace2ID&amp;QualDriver&amp;QSession,0)),INDEX(" &amp; _
                    "Race2Grid,MATCH(C2&amp;I2,QualRace2ID&amp;QualDriver,0)))))"

    With Worksheets("Races").Range("V2")
        .FormulaArray = theFormulaPart1
        .Replace "X_X_X())", theFormulaPart2
    End With

End Sub
</code></pre>

<p>I have tried splitting the formula onto more lines to make it easier to read.</p>