Creating my own search box to find a keyword and then an option to find next.

bosmond

New Member
Joined
Sep 30, 2014
Messages
1
Good morning all, I am having some problems with some code.

I want to be able to search for keywords in a spread sheet with the option to find next. I understand that I can press CTRL-f but I would like to have a cell with a search box. I have done all I can to get this to work but so far all It will do is find one of many keywords and not find the next in the spreadsheet. Code is below. Can anyone help me with this?

Sub Search_Click()

'Opens box and ask what do they want to search
searchthis = InputBox("Go get it Benny.", "Property Search")
'Tells where to search
Columns("A:P").Select
'and then search in them whatever the user entered:
Selection.Find(What:=searchthis, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext).Activate

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello and welcome to the Board

Try something like this:

Code:
Sub bosmond()
Dim c As Range, searchthis, fa$
searchthis = InputBox("Go get it Benny.", "Property Search")
With Columns("a:p")
    Set c = .Find(searchthis, ActiveCell, xlFormulas, xlPart, xlByRows, xlNext)
    If Not c Is Nothing Then
        fa = c.Address
        Do
            c.Activate
            MsgBox "Press OK to find next:", vbInformation, "Found at " & c.Address
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> fa
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top