Find and Color Macro

rcholst2

New Member
Joined
Dec 1, 2005
Messages
6
I need to select one variable in Column A Row 1 and check to see if it exists in Column B and then Makr it red if it does.

There are over 1000 variables in Column A that need to be found in Column B and marked.

I started doing this by hand with copying and pasing in the Find command and then coloring... after 50 my hand got tired....

Any suggestions for a Macro?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You can put a vlookup formula in conditional formatting.

Highlight your range in column A

Goto Format / Conditional Formatting

Change Cell Value Is to Formula Is

Enter
=VLOOKUP($A1,$B$1:$B$16,1,0)

Changing the range to fit your needs.

Choose the format to be red.

:cool:
 
Upvote 0
Select the data in column A, then select conditional formatting from the Format menu.

Enter a condition of

Formula is | =COUNTIF($B:$B,$A1)>=1

and click the format button to set the colors.

When you click OK it should highlight any cell in column A that is listed in column B.
 
Upvote 0
Macro idea

For a macro, here's what I would do:

Code:
Sub FindDuplicates()

'establish starting row numbers
rownumA=1
rownumB=1


Do While Cells(rownumA,1).value <>""

  Do While Cells(rownumB,1).Value <> ""
	If Cells(rownumA,1).Value = Cells(rownumB,2).Value Then
		Cells(rownumA,1).Font.ColorIndex = 3
		Exit Do
	Else
		rownumB=rownumB+1
	End If
  Loop

rownumA=rownumA+1
rownumB=1

Loop

End Sub
 
Upvote 0
This pair of Subs should be quite fast!


Sub myFindMatch()
'Run from standard module, like: Module1.
'Find and highlight each cell in Column: B, that matches a value in Column: A
Dim myRngLst As Range, myRngDat As Range, myFunct As Object

Set myFunct = Application.WorksheetFunction
Set myRngDat = Sheets("Sheet1").Range(Cells(1, 2), Cells(Range("B65536").End(xlUp).Row, 2))
Set myRngLst = Sheets("Sheet1").Range(Cells(1, 1), Cells(Range("A65536").End(xlUp).Row, 1))

For Each Cell In myRngDat
If (Cell.Value <> "" And myFunct.CountIf(myRngLst, Cell.Value) <> 0) Then
Cell.Interior.ColorIndex = 38
End If
Next Cell
End Sub


Sub myReSetColor()
'Run from standard module, like: Module1.
'Re-Set Column: B cell colors!
Dim myRngDat As Range

Set myRngDat = Sheets("Sheet1").Range(Cells(1, 2), Cells(Range("B65536").End(xlUp).Row, 2))
myRngDat.Interior.ColorIndex = xlNone
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,618
Messages
6,056,317
Members
444,858
Latest member
ucbphd

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