When trying to use an array formula I was getting:
Error 1004: "Unable to set the formulaarray property of the range class"
Research indicated that it was because my formula was too long, so I tried a "Replace" trick described by others.
I now get:
Runtime error '424': "Object required"
on my first .Replace
line.
For k = LastRow + 4 To LastRow + 3 + KeyListIndex
FormulaArrayString = "=MIN(IF('" & KeyDataRange & "='" & DataFindingsTab & "'!$A" & CStr(k) & ",'" & DateDataRange & "))"
With Sheets(DataFindingsTab).Cells(k, 2).FormulaArray = "=MIN(IF('KeyDataRange='" & DataFindingsTab & "'!$A" & CStr(k) & ",'DateDataRange))"
.Replace "KeyDataRange", TabName & " '!$" & Number2Letter(KeyCol) & "$2:$" & Number2Letter(KeyCol) & "$" & CStr(LastDetailRow)
.Replace "DateDataRange", TabName & " '!$" & Number2Letter(DateCol) & "$2:$" & Number2Letter(DateCol) & "$" & CStr(LastDetailRow)
End With
Next k
Variable FormulaArrayString
is in there to check my work, and watching it confirms that it matches the working array formula lin my worksheet.
Update: I've fixed the newline issue and also a few errant spaces I noticed, so now my code looks like this but I'm still getting the error:
For k = LastRow + 4 To LastRow + 3 + KeyListIndex
FormulaArrayString = "=MIN(IF('" & KeyDataRange & "='" & DataFindingsTab & "'!$A" & CStr(k) & ",'" & DateDataRange & "))"
With Sheets(DataFindingsTab).Cells(k, 2)
.FormulaArray = "=MIN(IF('KeyDataRange='" & DataFindingsTab & "'!$A" & CStr(k) & ",'DateDataRange))"
.Replace "KeyDataRange", TabName & "'!$" & Number2Letter(KeyCol) & "$2:$" & Number2Letter(KeyCol) & "$" & CStr(LastDetailRow)
.Replace "DateDataRange", TabName & "'!$" & Number2Letter(DateCol) & "$2:$" & Number2Letter(DateCol) & "$" & CStr(LastDetailRow)
End With
Next k
Is there a way to directly watch what's being passed to .FormulaArray
so I can make certain it is what it is supposed to be?
The formula I'm aiming for is:
=MIN(IF('1| Labor'!$B$2:$B$585='BOE Post-DoD Data Findings'!$A14,'1| Labor'!$E$2:$E$585))