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
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