I've been trying hard to figure out what went wrong here. I have two cols which contain string values. I use the third col to call a UDF in the worksheet, but end up getting #Value with error - "A value used in the formula is of wrong data type".
Eg:
Col I Col J
File1 Y
File1 N
File2 Y
File3 N
I tried debugging it, and the input values were passed fine into the function variables. My knowledge in VBA is limited, hoping you guys can help me out in resolving this issue.
Function called in worksheet:
=FileCheck(I3,I3:J38)
Code:
Public Function FileCheck(V As Range, Q As Range) As String
Dim vtest As Variant
Dim i, j, stat As Integer
stat = 0
vtest = Q
For i = 1 To UBound(vtest)
If V = vtest(i, 1) And vtest(i, 2) = "N" Then
For j = 1 To UBound(vtest)
If V = vtest(j, 1) And vtest(j, 2) = "Y" Then
FileCheck = "Y"
stat = 1
End If
Next
If stat = 0 Then
FileCheck = "N"
End
Else: End
End If
ElseIf V = vtest(i, 1) And vtest(i, 2) = "Y" Then
FileCheck = "Y"
End If
Next
End Function