Error:Unable to Set The FormulaArray Property of the Range Class

mlo356

Board Regular
Joined
Aug 20, 2015
Messages
51
Hi All,

I know this topic has been covered in great length but was not able to find anything that resolves my issue. I have a piece of code that is a FormulaArray but I am receiving the infamous error:

"Unable to Set The FormulaArray Property of the Range Class"

When I switch it from FormulaArray to FormulaR1C1, it will at least enter the code but it doesn’t evaluate properly because it needs to be an array formula. Here is the VB code:

Code:
Range("AO2").FormulaArray = "=IF(AND(RC2=""ACTIVITY RECEIVED"",IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl,Detail!RC[-10])),ROW(Key_Word_Tbl)),1)-1,0)>0),INDIRECT(""Logic!""&ADDRESS(IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl,Detail!RC[-10])),ROW(Key_Word_Tbl)),1)-1,0),4)),""NO"")"

Here is the formula in A1 Notation

Code:
=IF(AND($B2="ACTIVITY RECEIVED",IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!AE2)),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0)>0),INDIRECT("Logic!"&ADDRESS(IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!AE2)),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0),4)),"NO")

Anyone have any ideas as to why I can't code this as a FormulaArray? I am probably overlooking something. Any help would be appreciated.

Thanks!!
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi ,

Entering a formula using VBA is possible only if the formula length does not exceed 255 characters.

Your posted formula is more than that.

Try the following code to enter the formula :
Code:
Sub ArrayFormula()
    With ActiveSheet.Range("AO2")
        s = "=IF(AND(RC2=""ACTIVITY RECEIVED"",IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!RC[-10])),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0)>0),YYYY,""NO"")"
   
        Application.ReferenceStyle = xlR1C1


        .FormulaArray = s
   
        .Replace "YYYY", "INDIRECT(""Logic!""&ADDRESS(IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!RC[-10])),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0),4))", xlPart
   
        Application.ReferenceStyle = xlA1
    End With
End Sub
 
Upvote 0
Hi ,

Entering a formula using VBA is possible only if the formula length does not exceed 255 characters.

Your posted formula is more than that.

Try the following code to enter the formula :
Code:
Sub ArrayFormula()
    With ActiveSheet.Range("AO2")
        s = "=IF(AND(RC2=""ACTIVITY RECEIVED"",IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!RC[-10])),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0)>0),YYYY,""NO"")"
   
        Application.ReferenceStyle = xlR1C1


        .FormulaArray = s
   
        .Replace "YYYY", "INDIRECT(""Logic!""&ADDRESS(IFERROR(SMALL(IF(ISNUMBER(SEARCH(Key_Word_Tbl[KEY WORD EXCEPTIONS],Detail!RC[-10])),ROW(Key_Word_Tbl[KEY WORD EXCEPTIONS])),1)-1,0),4))", xlPart
   
        Application.ReferenceStyle = xlA1
    End With
End Sub


Hi NARAYANK991,

This worked perfect. Thank You!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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