Solved: Multiple search in one sheet EXCEL

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

SlickMlle

Thread Starter
Joined
Dec 21, 2012
Messages
3
Hi,
I need to search for multiple names (20-50) in one sheet which contains thousands of words. Is there a macro I can use? It's a very simple sheet and I can do the search in 1 column only if needed.
Thanks
 
Joined
Sep 4, 2003
Messages
4,916
Yes this can be done. Will the 20-50 names be listed in the same workbook? What do you want to do with the values that are found?

Rollin
 

SlickMlle

Thread Starter
Joined
Dec 21, 2012
Messages
3
Yes this can be done. Will the 20-50 names be listed in the same workbook? What do you want to do with the values that are found?

Rollin
Hello Rollin,
Thanks for the help.
Yes, all the names are in the same worksheet; I just need to locate them and highlight them.
 
Joined
Sep 4, 2003
Messages
4,916
I've provided 2 macros below. The first macro will search the entire sheet for matching values while the second macro will search a specific column for matching values. Just change the portions highlighted in red to match your sheet names / data layout.


USE THE FIRST MACRO BELOW TO SEARCH FOR MATCHING VALUES ON THE ENTIRE SHEET

Code:
Sub FindValues()

    '''Change to sheet name containing list of values to search
vListSheet = "[COLOR="Red"]Sheet2[/COLOR]"

    '''Change to column letter containing list of values to search
vListColumn = "[COLOR="Red"]A[/COLOR]"

    '''Change to row number of first value to search
vStartList = [COLOR="Red"]1[/COLOR]

    '''Change to sheet name where you would like to search
vFindSheet = "[COLOR="Red"]Sheet1[/COLOR]"


vLastRow = Sheets(vListSheet).Cells(Rows.Count, vListColumn).End(xlUp).Row


For Each vSearch In Sheets(vListSheet).Range(vListColumn & vStartList & ":" & vListColumn & vLastRow).Cells

Set vFound = Sheets(vFindSheet).Cells.Find(What:=vSearch, MatchCase:=False)

If Not vFound Is Nothing Then
vStart = vFound.Address

Do
Range(vFound.Address).Interior.ColorIndex = 6
Set vFound = Cells.FindNext(vFound)
Loop Until vFound.Address = vStart
End If

Next vSearch

End Sub
USE THIS MACRO TO SEARCH FOR MATCHING VALUES IN A PARTICULAR COLUMN

Code:
Sub FindValues2()

    '''Change to sheet name containing list of values to search
vListSheet = "[COLOR="Red"]Sheet2[/COLOR]"

    '''Change to column letter containing list of values to search
vListColumn = "[COLOR="Red"]A[/COLOR]"

    '''Change to row number of first value to search
vStartList = [COLOR="Red"]1[/COLOR]

    '''Change to sheet name where you would like to search
vFindSheet = "[COLOR="Red"]Sheet1[/COLOR]"

   ''''Change to column that you would like to search
vFindColumn = "[COLOR="Red"]C[/COLOR]"


vLastRow = Sheets(vListSheet).Cells(Rows.Count, vListColumn).End(xlUp).Row


For Each vSearch In Sheets(vListSheet).Range(vListColumn & vStartList & ":" & vListColumn & vLastRow).Cells

Set vFound = Sheets(vFindSheet).Columns(vFindColumn & ":" & vFindColumn).Cells.Find(What:=vSearch, MatchCase:=False)

If Not vFound Is Nothing Then
vStart = vFound.Address

Do
Range(vFound.Address).Interior.ColorIndex = 6
Set vFound = Cells.FindNext(vFound)
Loop Until vFound.Address = vStart
End If

Next vSearch

End Sub
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top