Problem trying to identify if cell is greater than

sharky12345

Well-known Member
I have a cell which is formatted as number with 2 decimal places, (current value is 24:53).

I have another cell which is formulated as general and has a current value of 30.

I'm trying to identify if the first cell is greater than the second one, in the example above the answer is false, but no matter what I try the answer I get with conditional formatting is wrong. I assume it's the way the cells are formatted but I need the current formatting to remain so can someone explain why it won't work?

I should add that ideally I'm trying to identify the result by VBA if possible.

Last edited:

Excel Facts

To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Dave Patton

Well-known Member
T202011b.xlsm
BCD
25030TRUE
324.5330FALSE
2d
Cell Formulas
RangeFormula
D2:D3D2=B2>C2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2Expression=B2>C2textNO
B3Expression=C3>B3textNO

Well-known Member
Test this (for cell C1 & D1):
VBA Code:
``````Sub test2()
If Range("C1").Value > Range("D1").Value Then
Cells(1, 3).Interior.Color = RGB(255, 0, 0)
Cells(1, 3).Borders.Color = RGB(192, 192, 192)
Cells(1, 4).Interior.Color = RGB(255, 255, 255)
Cells(1, 4).Borders.Color = RGB(192, 192, 192)
Else
Cells(1, 4).Interior.Color = RGB(255, 0, 0)
Cells(1, 4).Borders.Color = RGB(192, 192, 192)
Cells(1, 3).Interior.Color = RGB(255, 255, 255)
Cells(1, 3).Borders.Color = RGB(192, 192, 192)
End If
End Sub``````

Last edited by a moderator:

Thanks guys!

Replies
3
Views
272
Replies
6
Views
152
Replies
8
Views
234
Replies
2
Views
91
Replies
3
Views
143