Greetings I've been searching for a way to create a Search Box to search my Workbook. I found some code on this site, and while, it does work, there are a few things I don't like about it. Here is the code I'm using (slightly edited from it's original):
I'm using Excel 2016.
Sub FindRadio() 'add a command button on your Master Sheet referencing this Macro
res = InputBox("What radio are you looking for? Enter only the last four numbers.")
For w = 2 To Worksheets.Count
With Worksheets(w)
Set Rng = .Cells '<< The Entire Cell is Searched
With Rng
Set MyChoice = .find(What:=res)
If Not MyChoice Is Nothing Then
Application.Goto MyChoice
MsgBox "Found " & res & " on " & Worksheets(w).Name
Else
MsgBox "Could Not Find " & res & " on " & Worksheets(w).Name
End If
End With
End With
Next w
Worksheets(1).Activate
End Sub
My dislikes about it are: It searches each worksheet at a time and makes me click OK to proceed to the next worksheet (of which there are 10 in this workbook). I'd ideally like it to just search the whole workbook and take me to the found information, and maybe have a box that says something like, "Is this what you were looking for?" Clicking yes would end the search, clicking no would take me to the next occurrence, if any. Or if it didn't find the information, it would tell me and let me stop the search. I could live it the way it is, except for the fact that, when it finds the information, I still have to keep clicking OK until I make it through all the worksheets. There is an X at the top of the result box, but instead of stopping the process, the X acts like the OK button and takes me to the next worksheet until I've gone through each one. What I can change in here to get it to do what I'd like? Thanks.
I'm using Excel 2016.
Sub FindRadio() 'add a command button on your Master Sheet referencing this Macro
res = InputBox("What radio are you looking for? Enter only the last four numbers.")
For w = 2 To Worksheets.Count
With Worksheets(w)
Set Rng = .Cells '<< The Entire Cell is Searched
With Rng
Set MyChoice = .find(What:=res)
If Not MyChoice Is Nothing Then
Application.Goto MyChoice
MsgBox "Found " & res & " on " & Worksheets(w).Name
Else
MsgBox "Could Not Find " & res & " on " & Worksheets(w).Name
End If
End With
End With
Next w
Worksheets(1).Activate
End Sub
My dislikes about it are: It searches each worksheet at a time and makes me click OK to proceed to the next worksheet (of which there are 10 in this workbook). I'd ideally like it to just search the whole workbook and take me to the found information, and maybe have a box that says something like, "Is this what you were looking for?" Clicking yes would end the search, clicking no would take me to the next occurrence, if any. Or if it didn't find the information, it would tell me and let me stop the search. I could live it the way it is, except for the fact that, when it finds the information, I still have to keep clicking OK until I make it through all the worksheets. There is an X at the top of the result box, but instead of stopping the process, the X acts like the OK button and takes me to the next worksheet until I've gone through each one. What I can change in here to get it to do what I'd like? Thanks.