Hi, this is the first time I create a userform. So bare with me plz.
I have a command button called "search".
What I am trying to make it do: when the user types a word in textbox1 and then he clicks the search button. It will search for that word in column A to BA.
If he doesn’t find the searched word --> a message will appear in textboxe2 "no results found".
If there is a result --> it will copy the cells in texteboxe2. (The word can be found in multiple cells) EX: A50, A52, A70, D20, D30, D60, V45, V53 and V90
The result should look like this:
A1<-- the first cell of the column must appear before the result in that column.
A50
A52
A70
D1
D20
D30
D60
V1
V45
V53
V90
So far, I got this code and I am stuck:
Sub search_Click()
Dim FndCell As Variant, FndMe As String, SearchRng As Variant
Cells.Interior.ColorIndex = 0
FndMe = Range("textbox1").Value
Set SearchRng = Sheets(1).Range("A1", Range("B10000").End(xlUp))
Debug.Print SearchRng.Address
For Each cl In SearchRng
Set FndCell = cl.Find(what:=FndMe, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False, searchorder:=xlByRows)
If Not FndCell Is Nothing Then
FndCell.Interior.ColorIndex = 8
End If
Next cl
End sub
Thank you for the big help.
Bookmarks