I've been using StackOverflow for months and it has answered all of my questions, expect for the issue I'm currently having. I can't seem to fix the issue, no matter the options posted on this site. Maybe you can see the issue, that I'm not seeing at the moment.
I have one FormulaArray in VBA that takes the index of an external file, matches one value (Q2) with a value in column B of the external file. Then it matches a second value (P2) with a value in column D of the external file. If there's a match on both, it'll return a value that is in column C of the external file.
Works great in Excel, but the moment I create a Selection.FormulaArray = this formula, I get a 1004 in return. The line itself is shorter than 255 characters and even breaking up the INDEX and MATCH formulas into two parts (by Dim formulapart1 and formulapart2 as string) it doesn't work.
=INDEX([ISOCODE.xlsx]ISOCODE!$A:$D;MATCH(1;([ISOCODE.xlsx]ISOCODE!$B:$B=Q2)*([ISOCODE.xlsx]ISOCODE!$D:$D=P2);0);3)
I tried the following solution that was posted on this website that worked for others, but it's not working for me, no matter what I do:
Dim theFormulaPart1 As String
Dim theFormulaPart2 As String
theFormulaPart1 = "=INDEX([ISOCODE.xlsx]ISOCODE!$A:$D;XX"
theFormulaPart2 = "MATCH(1;([ISOCODE.xlsx]ISOCODE!$B:$B=Q2)*([ISOCODE.xlsx]ISOCODE!$D:$D=P2);0);3)"
With ActiveSheet.Range("DS2")
.FormulaArray = theFormulaPart1
.Replace "XX", theFormulaPart2
End With
XXuse999. 2. when using vba to insert a formula, one needs to useen-usformat. replace the;with,- Scott CranertheFormulaPart1needs to be viable as a stand-alone formula - currently, you're not closing the brackets! TrytheFormulaPart1="=INDEX([ISOCODE.xlsx]ISOCODE!$A:$D;999;3)", and remove;3)` from the end oftheFormulaPart2- Chronocidal