Unable to set the FormulaArray property of the Range class

breynolds0431

Active Member
Joined
Feb 15, 2013
Messages
303
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Keep getting the unable to set the FormulaArray property of the Range class error. I've tested the formula by manually adding to a cell and it works fine. But, I can't seem to find what the issue is. Any ideas on what is tripping this up?


VBA Code:
Sub Array ()

Dim theFormulaPart1 As String
Dim theFormulaPart2 As String
Dim theFormulaPart3 As String
Dim theFormulaPart4 As String
Dim theFormulaPart5 As String
Dim theFormulaPart6 As String

theFormulaPart1 = "=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C2,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C7,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8, BDR())"

theFormulaPart2 = "IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C12,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))"


theFormulaPart3 = "=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C3,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C8,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8, BDR())"
    
theFormulaPart4 = "IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C13,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))"


theFormulaPart5 = "=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C4,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C9,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8, BDR())"
    
theFormulaPart6 = "IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C14,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))"


Set wsh = Worksheets("MEDataGrab")

    i = 9
 
    While wsh.Cells(i, 2) <> ""

    With wsh.Cells(i, 4)
    .FormulaArray = theFormulaPart1
    .Replace "BDR())", theFormulaPart2
    
    End With
        
    With wsh.Cells(i, 5)
        .FormulaArray = theFormulaPart3
        .Replace "BDR())", theFormulaPart4
    
    End With
    
    With wsh.Cells(i, 6)
        .FormulaArray = theFormulaPart5
        .Replace "BDR())", theFormulaPart6
    
    End With

    wsh.Cells(i, 7).FormulaR1C1 = _
        "=IF(RC[-5]="""","""",IF(LEN(RC[-3])>2,VLOOKUP(NUMBERVALUE(LEFT(RC[-3],2)),Funding,3,FALSE),VLOOKUP(RC[-3],Funding,3,FALSE)))"
        
        i = i + 1
 
    Wend
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Can you post the formula you are trying to add to the cells?
 
Upvote 0
Yes, I have three different columns for the array formula. The error is only happening on the first columns, but I imagine it would do all columns if it were to skip.

Sorry if there's a better way to post these formulas...

1st Column (C4):

=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C2,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C7,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8,IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C12,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))

2nd Column (C5):

=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C3,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C8,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8, IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C13,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))

3rd Column (C6):

=IFERROR(INDEX('[MEDataFiles.xlsb]1'!C4,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C3,IF(RC3<='[MEDataFiles.xlsb]1'!C4,IF(RC2='[MEDataFiles.xlsb]1'!C1,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C9,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C8,IF(RC3<='[MEDataFiles.xlsb]1'!C9,IF(RC2='[MEDataFiles.xlsb]1'!C6,1))),0)),IFERROR(INDEX('[MEDataFiles.xlsb]1'!C14,MATCH(1,IF(RC3>='[MEDataFiles.xlsb]1'!C13,IF(RC3<='[MEDataFiles.xlsb]1'!C14,IF(RC2='[MEDataFiles.xlsb]1'!C11,1))),0)),"""""""")))
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,168
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top