drrocket5292
Technical User
I'm trying to write VBA code that will allow me to compare the cells in two list and then color the cell if it is in both lists. ive written code that works but im trying to add to it so that it not only colors that one cell but the entire row that it is in. can someone please tell me what i need to add to my code to make this happen? here is my code. thanks for the help.
Sub Color()
Dim Cell As Range
Dim r As Range
Dim n As Integer
Worksheets(Array("Sheet1", "Sheet2")).Select
Set r = Worksheets("sheet2").Range("a1:a100")
For Each Cell In Worksheets("Sheet1").Range("b1:B266")
For n = 1 To r.Rows.Count
If Cell.Value = Worksheets("sheet2").Cells(n, 1) Then _
Cell.Interior.ColorIndex = 48
Next n
Next Cell
End Sub
Sub Color()
Dim Cell As Range
Dim r As Range
Dim n As Integer
Worksheets(Array("Sheet1", "Sheet2")).Select
Set r = Worksheets("sheet2").Range("a1:a100")
For Each Cell In Worksheets("Sheet1").Range("b1:B266")
For n = 1 To r.Rows.Count
If Cell.Value = Worksheets("sheet2").Cells(n, 1) Then _
Cell.Interior.ColorIndex = 48
Next n
Next Cell
End Sub