Getting the Error Message: "Unable to set the FormulaArray property of the Range Class"

charmd1

New Member
Joined
Nov 21, 2019
Messages
3
Hi,

Thank you in advance for helping me. My goal is to instead of using the index/match function directly in the Excel cells, which looks up a value based on the concatenation of a date and value (unique). I would like to populate the cells in the backend us VBA with the index/match formula shown below, then copy and paste special those values in the same cells, so that the user only sees the actual values found by the index/match lookup and not see the actual excel index match formulas.

I started off by finding the starting row, ending row, and column number to create the range where I would like to perform the index match lookup. After that, I created the range, then used the FormulaArray property, but I got an error message. Not sure what I am doing wrong. Lastly, it'd be nice if the user can enter a date range and only the specified dates that match would get updated in the routine. Thanks again for your help!
Code:
Sub performanceUpdate()

Dim collatRange As Range
Dim sht As Worksheet
Dim lastRow As Long
Dim lastCol As Long
Dim rt As Long, cntCol As Long
Dim strField As String, strFieldnm As String

Worksheets("Performance").Select

'Find the last column

Range("I2").Select
cntCol = Range(Selection, Selection.End(xlToRight)).Count


'Find the start and end row

rt = 1

'Starting row

Do While strFieldnm <> "DEAL PERFORMANCE"

If Cells(rt, 1).Value <> "DEAL PERFORMANCE" Then
rt = rt + 1
strFieldnm = Cells(rt, 1).Value
End If
Loop

Dim perfStartRow As Long, perfEndRow As Long

perfStartRow = rt + 1

'Ending Row

Do Until strFieldnm = "COLLATERAL"

If Cells(rt, 1).Value <> "COLLATERAL" Then
rt = rt + 1
strFieldnm = Cells(rt, 1).Value
End If
Loop

perfEndRow = rt - 1

Dim rngPerformance As Range


Set rngPerformance = Range(Cells(perfStartRow, 9), Cells(perfEndRow, cntCol))


rngPerformance.FormulaArray = "=IFERROR(INDEX(Performance_Detail!$A:$CD,MATCH(R2C&""-""&RC2,INDEX(Performance_Detail!$A:$CD,,MATCH(R1C2,Performance_Detail!R1,0)),0),MATCH(RC3,Performance_Detail!R1,0)),"")"

'rngPerformance.Select
rngPerformance.Copy
rngPerformance.PasteSpecial xlPasteValues, xlPasteSpecialOperationNone

End sub
 
Last edited by a moderator:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You are mixing up A1 and R1C1 notation in the formula.

Try replacing Performance_Detail!$A:$CD with Performance_Detail!C1C82 in the formula.
 
Upvote 0
Oops, didn't notice the "" at the end of the formula, for that you need to double up.
Code:
rngPerformance.FormulaArray = "=IFERROR(INDEX(Performance_Detail!C1C82] ,MATCH(R2C&""-""&RC2,INDEX(Performance_Detail!C1C82 ,,MATCH(R1C2,Performance_Detail!R1,0)),0),MATCH(RC3,Performance_Detail!R1,0)),"""")"
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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