Thank you to BigBas for his great response!
I managed to get it to work for my project with some very minor changes. I'm running it from a second userform that loads from the first, and then plugs the details I need back into the first userform (so i had to hide rather than unload and return .text rather than the .value).
I added a third column to the Results.List and I added a Close button so the user can back out without selecting anything. I've also added another pop up to advise the user if no results were found.
I've put it through a bit of testing and it seems to stand up (I've had it return up to 37 matches from over 600 possible results without obvious error). This is my final code:
Private Sub SearchBTN_Click()
Dim ws As Worksheet
Dim rng As Range
Dim tSrch As String
Dim cnt As Long
Dim cel As Range
Set ws = Worksheets("JobsList")
Set rng = Intersect(ws.Range("A1").CurrentRegion, ws.Columns(2))
Me.Results.Clear
tSrch = CStr(Me.Search.Value)
cnt = WorksheetFunction.CountIf(rng, "*" & tSrch & "*")
If cnt > 0 Then
Me.Results.Visible = True
Else
MsgBox ("No results found.")
End If
t = 0
For Each cel In rng
If UCase(cel.Value) Like "*" & UCase(tSrch) & "*" Then
Me.Results.AddItem
Me.Results.List(t, 1) = cel.Offset(, -1).Value
Me.Results.List(t, 2) = cel.Value
Me.Results.List(t, 3) = cel.Offset(, 1).Value
Me.Results.List(t, 0) = cel.Address
t = t + 1
End If
Next cel
End Sub
Private Sub SelectBTN_Click()
UserForm1.MatterNo.Text = Me.Results.Text
UserForm6.Hide
UserForm1.Solicitor.SetFocus
End Sub
Private Sub CloseBTN_Click()
UserForm6.Hide
End Sub
Thanks again
Bookmarks