Unable to set the FormulaArray property of the Range Class

murthyspd

Board Regular
Joined
Dec 7, 2006
Messages
50
Hi
I am using Excel VBA to put an array formula using the FormulaArray property in the cell. But I get
"Unable to set the FormulaArray property of the Range Class" error

Sub ResponsibilityToAdd(Sht As String)


Dim LastRowRespToAdd As Integer
Dim LastRowinNewSheet As Integer
Dim i As Integer

Worksheets("ResponsibilityToBeAdded").Activate
LastRowRespToAdd = Range("A1").End(xlDown).Row



''=INDEX(ResponsibilityToBeAdded!A2:D701,MATCH(Sheet16!B2&Sheet16!C2&Sheet16!D2,TRIM(ResponsibilityToBeAdded!A2:A701)&TRIM(ResponsibilityToBeAdded!B2:B701)&TRIM(ResponsibilityToBeAdded!C2:C701),0),4)

Worksheets(Sht).Activate
LastRowinNewSheet = Range("A1").End(xlDown).Row



For i = 2 To LastRowinNewSheet

If Range("B" & i) = "Others" Then
Range("F" & i) = Range("C" & i)
Else

Range("F" & i).FormulaArray = "=INDEX(ResponsibilityToBeAdded!A2:D" & LastRowRespToAdd & ",MATCH(" & Sht & "!B" & i & Sht & "!C" & i & _
Sht & "!D" & i & ",TRIM(ResponsibilityToBeAdded!A2:A" & LastRowRespToAdd & ")&TRIM(ResponsibilityToBeAdded!B2:B" & LastRowRespToAdd & _
")&TRIM(ResponsibilityToBeAdded!C2:C" & LastRowRespToAdd & "),0),4)"
End If
Next i


End Sub

Can somebody assist what could be the cause
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi

The formula has probably more than 255 characters which is not allowed to assign directly.
You must do a 2 step assignment. First assign a simplified version of the formula and then replace part of it with the remaining.

I don't have time now to post a solution but you can seach this board for several posts with the solution.
If you can't find it post back and I'll post a link later.
 
Upvote 0
Thanks pgc01. I could resolve the issue. The error was with the formula. The length was less than 255. Thanks for the help


Regards
Murthy
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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