I use this formula:
=IFERROR(IF(MATCH(transf(E7);transf(Sheet2!$C$2:$C$66648);0)>0;"YES");"no")
transf
is a UDF which simply converts/transforms the actual text value in cell to lowercase and does some other stuff (not the subject for this question).
Normally, if the value of transf(E7)
is found in the formed array transf(Sheet2!$C$2:$C$66648)
, the formula returns YES
, if no - no
.
The UDF itself works well, it is tested many times. The problem is that this time it does not work. The returned answer is no
, and it's not correct. Is this formula failure related to the big array of 66k+ items? What are the limitations of UDFs used as array formulas?
EDIT 1
This is the simplified version of my UDF:
Public Function transf(ByVal vText As Variant) As Variant
Dim aText() As Variant
Dim j As Long
On Error GoTo ErrH
If TypeName(vText) = "String" Then
'...some code...
ElseIf TypeName(vText) = "Variant()" Then
'...some code...
ElseIf TypeName(vText) = "Range" Then ' <<< both instances of the UDF fall here
ReDim aText(1 To vText.Count)
For j = 1 To vText.Count
aText(j) = Trim(LCase(vText(j)))
Next
transf = Application.Transpose(aText) ' <<< this line causes an error 13
Else
transf = CVErr(xlErrValue)
End If
ErrH:
'This was created not for the current case, but the error the UDF gets has the same #
If Err.Number = 13 Then
Err.Clear
Resume Next
End If
End Function
If you notice any other imperfections in case of performance, please, let me know.
EDIT 2
I'm using Excel 2010. No compatibility mode, the file itself - .xlsm, the UDF is in .xlam add-in file.