Hi all,
I am using a standard find routine to find the first match for a set of search critera. I then wish to display this crieria in a user form, but I am unsure of how to extract the range of the find result in to suitable variables to do this.
This is the code I am using.
Sub AdminSearch()
' Admin Search Macro
' Searchs the database and displays the entries one at a time on the Options Form
Dim rngFound As Range
SearchString = Options.txtSearchText.Value
' Searchs for a Match
If Options.chkSurname.Value Then
Set rngFound = Range("C:C").Find(SearchString)
End If
If Options.chkPacketContents.Value Then
Set rngFound = Range("M:N").Find(SearchString)
End If
If Options.chkPacketNo.Value Then
Set rngFound = Range("M:N").Find(SearchString)
End If
' If a match is found then the results are displayed
If Not rngFound Is Nothing Then
' Display Results in box
Else
MsgBox "No Matches for '" & SearchString & "' were found."
End If
Set rngFound = Nothing
End Sub
So for example, if I was to search 'Gould' and the rusult was found in "C493", I would like to assign the values in "A493:R493" ('txtDateOpened.text = range("A493").value'), but obviously the result will not always be "C493". Hope that makes sense!
Any help is greatly appricated.
Thanks.
Bookmarks