I am utilising a userform to find related records and displaying the results in specific fields on the form. I can scroll through these records using spin buttons. I also have a listbox that I want to limit to only show the results from the initial find query instead of everything that is on the sheet. My request is:
1. How can i limit the results in the listbox to only show the results from the find query?
2. I want to update or edit the related record based on what was found.
Here is my code for the find button:
Code: Select all
Public Sub BtnFind_Click()
'**********************************
Dim ws As Worksheet
Set ws = Sheets("DATA")
With ws
ws.Activate
'find Record
If Me.BxFDate.Value = "" Then
MsgBox "please enter a date to search for"
Exit Sub
End If
strFind = Me.BxFDate.Value
Set c = rsearch.Find(What:=strFind, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not c Is Nothing Then 'found it
Init_FindResults
Show_FindResults
With LstResults 'populate the listbox
.RowSource = "DATA!A2:U390" ' this should be limited to only show the results from the find query, not the entire sheet
.ColumnHeads = True
' .List = [TblList].Value
.ColumnCount = 11
.ColumnWidths = "60;60;60;80;120;140;50;80;60;60;60"
End With
Else
MsgBox "No exact match was found. Please try again"
End If
End With
'***********************************
End Sub