Hi all,
I have an Excel Userform that updates existing records. My current form has a "Search" button that uses a value typed into a serach field (txtSearch) and looks through Column D on the DataList (Sheet2) tab for that record. I would like to be able to allow the user to click on the Seach button again to search through the rest of the column for any more matches. Once the row is identified it updates the rest of the control boxes in the userform via a "populate userform" sub. I've been searching around the web and Help documents and found the .FindNext command but I can't seem to get it to work. Below is the current vba I have for the search button. Could someone please help me figure this out?
Thank you,
Jacob
I have an Excel Userform that updates existing records. My current form has a "Search" button that uses a value typed into a serach field (txtSearch) and looks through Column D on the DataList (Sheet2) tab for that record. I would like to be able to allow the user to click on the Seach button again to search through the rest of the column for any more matches. Once the row is identified it updates the rest of the control boxes in the userform via a "populate userform" sub. I've been searching around the web and Help documents and found the .FindNext command but I can't seem to get it to work. Below is the current vba I have for the search button. Could someone please help me figure this out?
Thank you,
Jacob
PHP:
Private Sub CommandButton4_Click()
Dim rw As Long 'row the search value was found on'
Dim cell As Range
Dim myVal As String
'validate user input'
If txtSearch.Value = "" Then
MsgBox "Enter valid Initiative!"
txtSearch.SetFocus
Exit Sub
End If
'convert the TexBox value to data type long and get row number'
myVal = txtSearch.Value
On Error Resume Next
With Sheets("DataList").Range("D:D")
Set cell = .Find(myVal, LookIn:=xlValues)
rw = cell.Row
End With
On Error GoTo 0
If rw = 0 Then
MsgBox "Initiative Not Found"
Else
Call PopulateTextBoxes(rw)
End If
End Sub