I want to compare two cells based upon their color they are having.
I created the following function. If the two colors in a cell match then it should write Same
and color the cell green
in the cell, else 'Change' and color it red
.
However, I am currently getting:
In the #Value
cells my formula is =ColorComparer(H4;C4)
Below you can find my vba function that I created:
Function ColorComparer(rColor As Range, rRange As Range)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If rCell.Interior.ColorIndex = lCol Then
vResult = "Same"
vResult.Interior.ColorIndex = RGB(0,255,0)
Else
vResult = "Change"
vResult.Interior.ColorIndex = RGB(255,0,0)
End If
ColorComparer = vResult
End Function
I really apprecaite your replies!
Best regards!
Changed
with background colorred
orSame
with background colorgreen
- Carol.Kar