This post is actually a response to a question someone had.
i need help comparing two cells with a high and low value, one of the cells is blue. Return 1 if the lowest value is blue color or return zero if the higher value is blue color. how do i perform this task in excel?
Here in this example we have 2 columns:
In order to evaluate the 2 columns, it’s best to generate a user defined function.
This is the code for the user defined function (in a module):
Public Function EvaluateCellContents(Row) As Integer
Dim intResult As Integer
Dim intRow As Integer
Dim strBlue As String
Dim strBlack As String
strBlue = 13998939
strBlack = 0
intRow = Row
intResult = 0
'DOES RANGE A HAS A BLUE FONT COLOR?
If Range("A" & intRow).Font.Color = strBlue Then
'IS THE BLUE VALUE LOWER?
If Range("A" & intRow) < Range("B" & intRow) Then
intResult = 1
Else
intResult = 0
End If
End If
'DOES RANGE B HAS A BLUE FONT COLOR?
If Range("B" & intRow).Font.Color = strBlue Then
'IS THE BLUE VALUE LOWER?
If Range("B" & intRow) < Range("A" & intRow) Then
intResult = 1
Else
intResult = 0
End If
End If
EvaluateCellContents = intResult
End Function
This is the way to call it from the worksheet:
=EvaluateCellContents((ROW(A4)))
and here is the end result:
Let me know if you have any questions.
****************************************************
|
|


