Hello,
I am trying to create a macro that will check each cell value in a specified range of cells to see if the cell value is less than or equal to the value in a static row and same column as the cell value that is being checked. If the cell value being checked is null nothing will change. If the cell value is less than or equal to the compared value, the cell interior color will change to green, else the cell interior color will change to red.
I will have to repeat this on multiple ranges within my worksheet.
My code so far changes the interior color of all cells in the range.
I am new to VBA so forgive my ignorance.
Here is my current code:
Sub Change_Cell_Color()
Dim MyCell As Variant
For Each MyCell In Range("B7:G24")
If Not IsNull(MyCell <= Cells(, 6).Value) Then
MyCell.Interior.Color = RGB(0, 255, 0)
Else
MyCell.Interior.Color = RGB(255, 0, 0)
End If
Next MyCell
End Sub
Any help is greatly appreciated. Thank you for your help and time.
I am trying to create a macro that will check each cell value in a specified range of cells to see if the cell value is less than or equal to the value in a static row and same column as the cell value that is being checked. If the cell value being checked is null nothing will change. If the cell value is less than or equal to the compared value, the cell interior color will change to green, else the cell interior color will change to red.
I will have to repeat this on multiple ranges within my worksheet.
My code so far changes the interior color of all cells in the range.
I am new to VBA so forgive my ignorance.
Here is my current code:
Sub Change_Cell_Color()
Dim MyCell As Variant
For Each MyCell In Range("B7:G24")
If Not IsNull(MyCell <= Cells(, 6).Value) Then
MyCell.Interior.Color = RGB(0, 255, 0)
Else
MyCell.Interior.Color = RGB(255, 0, 0)
End If
Next MyCell
End Sub
Any help is greatly appreciated. Thank you for your help and time.