-
Jan 6th, 2017, 10:16 AM
#1
Thread Starter
Addicted Member
VBA sub to conditionally test ranges with other cells value (colors the cell)
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
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
Last edited by habenero; Jan 6th, 2017 at 10:20 AM.
Reason: more info
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|