Excel Search macro

rondy

New Member
Joined
Sep 10, 2011
Messages
4
Any help with this would be greatly appreciate it as I am at a dead end with it.
I have an Excel workbook with 5000 entries with 16 tabs. I want to have a search engine that would go through the whole work book and show me the results .I also want either after showing the results ask me to search again for another entry and have it as a toolbar that I can simply search.Also I wanted to pop up when I open the workbook. here is what I was able to come up with but has a lot of flaws and doesnt do most of the things I wanted to.

Sub FindAll()
Dim strFind As String
Dim wks As Worksheet
Dim rngFound As Range
Dim lngItems As Long
strFind = InputBox(Prompt:="Enter Name to find", Title:="Vendor Search?")
If Len(strFind) > 0 Then
For Each wks In ActiveWorkbook.Worksheets
If FindIt(wks, strFind, lngItems) = False Then Exit For
Next wks
End If
MsgBox lngItems & " matches found"
End Sub
Function FindIt(wks As Worksheet, strFind As String, lngMatches As Long) As Boolean
Dim rngFound As Range
Dim strFirstFind As String
FindIt = True
With wks.UsedRange
Set rngFound = .Find(what:=strFind, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Not rngFound Is Nothing Then
strFirstFind = rngFound.Address
Do
lngMatches = lngMatches + 1
Application.Goto rngFound, True
If MsgBox("Found item. Do you wish to continue search?", vbYesNo) = vbNo Then
FindIt = False
Exit Do
End If
Set rngFound = .FindNext(rngFound)
Loop While rngFound.Address <> strFirstFind
End If
End With
End Function
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Maybe standard Excel tool "Find" will be helpful: there is possibility to seach in whole workbook (section "Options") and "Find All".
 
Upvote 0
thanks for the response ,but the CTRL+F is not practical in my case. Since the people who will be using it are savvy enough ,and everything has to be black and white before them.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,820
Members
452,946
Latest member
JoseDavid

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