In need of help with a search code - Macros Excel 2010

KyleJackMorrison

Board Regular
Joined
Dec 3, 2013
Messages
107
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Hello I'm in need of help.
Right here is the back story,
I'm currently away with the United Nations and a apart of my job is to search peoples names and registration before they enter the base. At the moment we have to search over 500 peoples names on a sheet of paper...
I've made an excel sheet with their names and registration numbers on.

I've got a code that I saw on the internet but I would like to tweak it but don't know how.
I would much appreciate it if someone could help me do this:
1. When searching a name it could highlight the row to make it more visible but not permanently highlight it.
2. After the search it could reopen the search box again.
3. Maybe to make it more easy, have a button that would link you to the search pop-up.

Just making this more easier because we have different nationalities that have to use this.

Code:
 Sub FindAll()   Dim strFind As String
   Dim wks As Worksheet
   Dim rngFound As Range
   Dim lngItems As Long
   strFind = InputBox(prompt:="Type in a name or registration to search..", Title:="Search Box,")
   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 items. Is this what you are looking for?", vbYesNo) = vbYes Then
               FindIt = False
               Exit Do
            End If
            Set rngFound = .FindNext(rngFound)
         Loop While rngFound.Address <> strFirstFind
      End If
   End With
End Function

Many thanks,
Kyle
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
You are in the wrong area for this post. You are in Microsoft Access and you might see responses if you post this in the excel section.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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