I am having an issue for excel formula index/match with IFERROR and it is working fine in excel when I am running it manually however after writing into Macro it is not working. this formula is created for doing matching and look-ups at multiple conditions and give the output result.
I am getting following error while running macro Run-time error'1004': Unable to set the FormulaArray property of the Range class.
Range("O2").Select
Selection.FormulaArray = _
"=IFERROR(INDEX('[NAL for Macro.xlsb]Sheet1'!C13,MATCH(1,('[NAL for Macro.xlsb]Sheet1'!C8=RC[-8])*(LEFT('[NAL for Macro.xlsb]Sheet1'!C3,15)=LEFT(RC[-13],15)),0)),IFERROR(VLOOKUP(RC[-8],'[NAL for Macro.xlsb]Sheet1'!C8:C15,6,0),IFERROR(VLOOKUP(RC[-8],'[NAL for Macro.xlsb]Sheet1'!C9:C15,5,0),(VLOOKUP(LEFT(RC[-13],15)&""*"",'[NAL for Macro.xlsb]Sheet1'!C3:C15,11,0)))))"
then I splitted the formula in to two parts as done below. Macro coding is running and not giving any error but replace doesn't happen. I am bit new to macro and tried hard as per my knowledge but it is not working Can anyone please help to guide me.
Sub Macro19()
'
' Macro19 Macro
'
'
With ActiveSheet.Range("O2")
Selection.FormulaArray = "=IFERROR(INDEX('[NAL for Macro.xlsb]Sheet1'!C13,MATCH(1,('[NAL for Macro.xlsb]Sheet1'!C8=RC[-8])*(LEFT('[NAL for Macro.xlsb]Sheet1'!C3,15)=LEFT(RC[-13],15)),0)),XX)"
.Replace "XX", "IFERROR(VLOOKUP(RC[-8],'[NAL for Macro.xlsb]Sheet1'!C8:C15,6,0),IFERROR(VLOOKUP(RC[-8],'[NAL for Macro.xlsb]Sheet1'!C9:C15,5,0),(VLOOKUP(LEFT(RC[-13],15)&""*"",'[NAL for Macro.xlsb]Sheet1'!C3:C15,11,0)))))"
End With
End Sub
So far I have changed coding with .Replace "'ws'", "'[NAL for Macro.xlsb]Sheet1'" and below is the revised. It is running successfully and no error is coming back but .Replace doesn't happening till yet and output result is coming #NA. Please help to resolve this.
Sub Macro20()
'
' Macro20 Macro
'
'
With ActiveSheet.Range("O2")
.FormulaArray = _
"=IFERROR(INDEX('ws'!C13,MATCH(1,('ws'!C8=RC[-8])*(LEFT('ws'!C3,15)=LEFT(RC[-13],15)),0)),IFERROR(VLOOKUP(RC[-8],'ws'!C8:C15,6,0),IFERROR(VLOOKUP(RC[-8],'ws'!C9:C15,5,0),(VLOOKUP(LEFT(RC[-13],15)&""*"",'ws'!C3:C15,11,0)))))"
.Replace "'ws'", "'[NAL for Macro.xlsb]Sheet1'"
End With
End Sub