Hi Guys,
I am hoping you can help me with this one. I am trying to build a search userform in excel that will allow the user to search using 1 of 3 possible search strings: Post Code, Check Number 1 and Check Number 2.
Now I am able to create a find function to work using a search that works using one search string, be it either Post Code, ChcNum1 or ChcNum2, however when I try to create one that will cancel out the other two based on the user input something goes awry in the code.
See the code below for help.
Private Sub cmdSearch_Click()
Application.ScreenUpdating = False
If ChcNumSrch <> 0 Then
TextBox1.Value = ""
TextBox3.Value = ""
Dim ragFound As Range
Set ragFound = Sheets("Details").Columns(29).Find(ChcNumSrch, Lookat:=xlWhole, Searchorder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not ragFound Is Nothing Then
FndSite1.Value = ragFound.Offset(, 13).Value
Else
MsgBox "Reference number is not found."
End If
If TextBox1 <> 0 Then
TextBox3.Value = ""
ChcNumSrch.Value = ""
Dim ragFound2 As Range
Set ragFound2 = Sheets("Details").Columns(21).Find(TextBox1, Lookat:=xlWhole, Searchorder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not ragFound2 Is Nothing Then
FndSite1.Value = ragFound2.Offset(, 21).Value
Else
MsgBox "Reference number is not found."
End If
End If
End If
Application.ScreenUpdating = True
End Sub
Please help, any input is greatly appreciated and you guys have been a great help in the past.
Thanks in advance!
Bookmarks