Hey yall,
I need help programming an inputbox that will search a range and return the findings in a msgbox. Im new to vba so please talk to me like an infant . I would like to launch the input box with a button. If match is found then fire a msgbox displaying the row contents of the match. If no match found then msgbox No Match. Sorry if im asking alot, im new so be gentle.

Search Box Via Inputbox that returns findings via msgbox
-
-
-
Re: Search Box Via Inputbox that returns findings via msgbox
See these links to get started. There are many more to be had with just little more search effort.
Collect User Data/Input via an InputBox
-
Re: Search Box Via Inputbox that returns findings via msgbox
Thanks for pointing me in the right direction. However the help files are even a tad complicated. All i need is a an Inputbox that you put the key word in, then when it finds the keyword it displays the entire row contents in a msgbox. Please help
-
Re: Search Box Via Inputbox that returns findings via msgbox
Do you mean all the cells in the corresponding row? How many cells are you looking at?
Code
Display MoreSub FindValueAndDisplayContentsOfCorrespondingRow() Dim rng As Range Dim lngColumns As Long Dim strMessage As String On Error Resume Next Set rng = Columns("A:A").Find(InputBox("Please enter your search parameter.", "Search...", "Text Here")) Err.Clear: On Error GoTo -1: On Error GoTo 0 If Not rng Is Nothing Then For lngColumns = 1 To 4 'This will show the next 4 cells of the row strMessage = strMessage & rng.Offset(, lngColumns).Value & vbCrLf Next lngColumns MsgBox strMessage Else MsgBox "No Match Found!" End If Set rng = Nothing lngColumns = Empty strMessage = vbNullString End Sub
-
Re: Search Box Via Inputbox that returns findings via msgbox
Hey SMC, yes i would like to return all the cells in the corresponding row. I have a worksheet with 7 columbs and 1500 rows. My goal is to search for " invoice #" or " PO # " and have the msgbox display these with the other 6 factors of the matching row.
-
Re: Search Box Via Inputbox that returns findings via msgbox
SMC this code works great!! But its limited to one search term. i.e column A only. Can it be adapted for 2 or 3 search tearms with the same result?
-
Re: Search Box Via Inputbox that returns findings via msgbox
If you want to search on more columns, like A to C, use Columns("A:C").
If you want to search for multiple texts from the same input box, confirm that, code can be revised.
If this is not what you meant, please clarify.
-
Re: Search Box Via Inputbox that returns findings via msgbox
I got it sorted with your code SMC. I used four instances of your code and defined each for specific searches i.e...A:A -1 to 7 would search for and return all cells including what i searched for. I did this for the four search criteria i needed. Thanks a million SMC you truley are a master of your craft. God Bless.:music:
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!