In a userform (VIEWM) I am adding a variable range "B4:B88" at the moment from sheet "CROSSREF" to create an array named SrchMe, I then want filter to compare a textbox value "FndThis" to the array and return an array of matches called "OutP1".
Both of the message boxes return appropriate responses, option explicit is at top of page.
The cells contain chemical reference numbers called CAS numbers in the format 123-45-6 or similar, but I have changed the array to contain text and this also fails.
Any help appreciated.
Code
Private Sub CASNAMESCH_Change()
Dim FndThis As String
Dim LastRw As Integer
Dim SrchMe(), OutP1() As Variant
LastRw = Sheets("CROSSREF").Cells(1, 1).End(xlDown).Row
SrchMe = Range(Sheets("CROSSREF").Cells(4, 2), Sheets("CROSSREF").Cells(LastRw, 2))
FndThis = VIEWM.CASNAMESCH.Value
MsgBox (SrchMe(1, 1))
MsgBox (FndThis)
OutP1 = Filter(SrchMe, FndThis) 'MISMATCH ERROR on this line.
MsgBox (OutP1(1, 1))
End Sub
Display More
Regards
Justin