search for value in cell located in adjacent column

zraj07

Board Regular
Joined
Jun 15, 2006
Messages
80
Column A has list of numbers. For simplicity, say they are 3, 15, 12, 16, 8.
Column B has a list of numbers. Say they are 1, 18, 27, 15, 8, 12, 16, 19, 34, 45...

Without changing the sort orders of these numbers, I am trying to write some code that will first consider Cell A1 (value of 3) , and will go search every value in Column B looking for a 3. If it finds any with a value of 3, it sets the interior.color to red.

Then, it would move to A2 (value of 15) and look for that in Column B, color them red if found, and move on to A3 (value of 12) and color them red.

I can't figure out how to use the cells method to keep track of where I am in Column A while searching Column B.

Any suggestions? Maybe I need to use some sort of Range operation?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can do this with conditional formatting, VBA not required...


Highlight all the values in Column B
Conditional Formatting
Formula
=MATCH(B1,$A$1:$A$5,0)
Format for red


Excel Workbook
AB
131
21518
31227
41615
588
612
716
819
934
1045
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B11. / Formula is =MATCH(B1,$A$1:$A$5,0)Abc
B21. / Formula is =MATCH(B2,$A$1:$A$5,0)Abc
B31. / Formula is =MATCH(B3,$A$1:$A$5,0)Abc
B41. / Formula is =MATCH(B4,$A$1:$A$5,0)Abc
B51. / Formula is =MATCH(B5,$A$1:$A$5,0)Abc
B61. / Formula is =MATCH(B6,$A$1:$A$5,0)Abc
B71. / Formula is =MATCH(B7,$A$1:$A$5,0)Abc
B81. / Formula is =MATCH(B8,$A$1:$A$5,0)Abc
B91. / Formula is =MATCH(B9,$A$1:$A$5,0)Abc
B101. / Formula is =MATCH(B10,$A$1:$A$5,0)Abc
 
Upvote 0
Solution

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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