# VBForums CodeBank > CodeBank - Other >  VBA sub to conditionally test ranges with other cells value (colors the cell)

## habenero

I am presently using Excel 2000 and there are only 3 conditional rules that I can use so I had to expand on that.

This code is simple and basic - It will take a larger range and test those values (for equality) with other cell values and turn those cells green

Just adjust "myRange" and the other cell(s) to match your needs

(this is my 1st code ever posted :Smilie: 


Sub Color_tester()
Set myRange = Range("A3:F8")
For Each cell In myRange
If cell.Value = Range("A10") Then
cell.Interior.ColorIndex = 4
ElseIf cell.Value = Range("B10") Then
cell.Interior.ColorIndex = 4
ElseIf cell.Value = Range("C10") Then
cell.Interior.ColorIndex = 4
ElseIf cell.Value = Range("D10") Then
cell.Interior.ColorIndex = 4
ElseIf cell.Value = Range("E10") Then
cell.Interior.ColorIndex = 4
ElseIf cell.Value = Range("F10") Then
cell.Interior.ColorIndex = 4
End If
Next
End Sub

----------

