Search or FIND on a userform.

  • Thread starter Thread starter Phillips
  • Start date Start date
P

Phillips

I want to put a SEARCH or a FIND feild on my userform.

Here is what I currently have:

Private Sub CommandButton48_Click()
'MsgBox TextBox86
If TextBox86 <> "" Then
Dim found As Range
With Worksheets("Master")
Set found = .UsedRange.Find(TextBox86, LookIn:=xlValues)
If Not found Is Nothing Then
MsgBox TextBox86 & " Found!"
Else
MsgBox TextBox86 & " Not Found!"
End If
End With
Else

MsgBox "Search Criteria was empty..."

End If

End Sub

How do I restuff all of the screen items? do I just reinitialize
everything? will it be on the right record?
Is there a way to get it to look even in hidden rows?
How do I do a find Next/Prev?

Thanks
Phil
 
Or (even better yet...)
Is there a simple way to impliment something like SQL using my current
userform or something???
 
Adding "SearchDirection" and "After" to the Find method
will help. For this the found cell needs to be
selected...actually not quite true, but with the code as
is...

Private Sub CommandButton48_Click()
'MsgBox TextBox86
If TextBox86 <> "" Then
Dim found As Range
With Worksheets("Master").Cells
If found Is Nothing Then Set found = Selection
Set found = .Find(TextBox86, after:=found,
LookIn:=xlValues, searchdirection:=xlNext)

If Not found Is Nothing Then
MsgBox TextBox86 & " Found!" & found.Address
found.Select
Else
MsgBox TextBox86 & " Not Found!"
End If
End With
Else

MsgBox "Search Criteria was empty..."

End If

End Sub


Patrick Molloy
Microsoft Excel MVP
 
Back
Top