Find same value in Sheet 2

bmacias

Board Regular
Joined
Sep 11, 2002
Messages
213
Hi All,

I have three values stored in sheet1 in cells a1, a2, and a3. What code do I use to look for one of these values in sheet 2 range a1:a10?

Thanks for your help.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
Hi bmacias,

Try this:

<pre>Sub findit()
Dim FindMe As String, c As Range, TestArea As Range, firstaddress As String

FindMe = ThisWorkbook.Sheets("Sheet1").Range("A1").Value 'change to suit
Set TestArea = ThisWorkbook.Sheets("Sheet2").Range("A1:A10")

With TestArea
Set c = .Find(What:=FindMe, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstaddress = c.Address
Do
c.Interior.ColorIndex = 4
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With

Set TestArea = Nothing
Set c = Nothing

End Sub</pre>

HTH
 

Forum statistics

Threads
1,144,734
Messages
5,725,982
Members
422,652
Latest member
Elnene1

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
Top