I am totally confused with this one...
If I use this then its entering the formula in A1 cell and I have to press CTRL+SHIFT+ENTER to make it as array and its returning the right result.
Range("A1").Value = "=INDEX(" & rRes.Address(, , , True) & ",SMALL(IF((" _
& rEmpNo.Address(, , , True) & "=" & vEmpNo.Address(, , , True) & ")*(" & rDate.Address(, , , True) & ">=" _
& vStDate.Address(, , , True) & ")*(" & rDate.Address(, , , True) & "<=" & vEndDate.Address(, , , True) & "),ROW(" _
& rDate.Address(, , , True) & ")-ROW(" & rDate.Cells(1).Address(, , , True) & ")+1),ROW(A1)))"
The result of the above formula in A1 cell is
=INDEX('Leave Credit'!$D$2:$D$8,SMALL(IF(('Leave Credit'!$B$2:$B$8='Leave card'!$D$10)*('Leave Credit'!$D$2:$D$8>='Leave card'!$C$8)*('Leave Credit'!$D$2:$D$8<='Leave card'!$F$8),ROW('Leave Credit'!$D$2:$D$8)-ROW('Leave Credit'!$D$2)+1),ROW(A1)))
After CTRL+SHIFT+ENTER it is returning the right results.
But when I use evaluate with this
Range("A1").Value = Evaluate("=INDEX(" & rRes.Address(, , , True) & ",SMALL(IF((" _
& rEmpNo.Address(, , , True) & "=" & vEmpNo.Address(, , , True) & ")*(" & rDate.Address(, , , True) & ">=" _
& vStDate.Address(, , , True) & ")*(" & rDate.Address(, , , True) & "<=" & vEndDate.Address(, , , True) & "),ROW(" _
& rDate.Address(, , , True) & ")-ROW(" & rDate.Cells(1).Address(, , , True) & ")+1),ROW(A1)))")
It's returning #Value as result....
If I use it in this way
Range("A1").FormulaArray = "=INDEX(" & rRes.Address(, , , True) & ",SMALL(IF((" _
& rEmpNo.Address(, , , True) & "=" & vEmpNo.Address(, , , True) & ")*(" & rDate.Address(, , , True) & ">=" _
& vStDate.Address(, , , True) & ")*(" & rDate.Address(, , , True) & "<=" & vEndDate.Address(, , , True) & "),ROW(" _
& rDate.Address(, , , True) & ")-ROW(" & rDate.Cells(1).Address(, , , True) & ")+1),ROW(A1)))"
Then it's returning...
Run-time error 1004
Unable to set the formulaArray property of the range class.
Bookmarks