I am trying to create a VBA function to consolidate two arrays that is generated from a sub. The objective is to compare to values contained in each array and to put any duplicated values into a new array and to finally pass the array back into the sub. There has been several variations of this function and I have attempted to create a function based off of these functions but my function currently enouncters a 'invalid or unqualified reference' when I try to use the built in .Match function. I would greatly appreciate it if anyone can take a quick look at my code below and let me know what's wrong!
Code:
Function lnArray(X As Variant, Y As Variant) As Variant
Dim counter1 As Long
Dim xcount As Long
Dim t As Long
Dim FinalResults() As Variant
For xcount = LBound(X) To UBound(X)
t = .Match(X(xcount), Y, 0)
If (t > 0) Then
counter1 = counter1 + 1
ReDim Preserve FinalResults(counter1)
FinalResults(counter1) = X(xcount)
End If
Next xcount
lnArray = FinalResults
End Function