Problem trying to identify if cell is greater than

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,338
Office Version
  1. 2016
Platform
  1. Windows
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:

Some videos you may like

Excel Facts

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

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
4,525
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,115
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
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:
Solution

Watch MrExcel Video

Forum statistics

Threads
1,119,223
Messages
5,576,827
Members
412,748
Latest member
MikeyP14
Top