Problem trying to identify if cell is greater than

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
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:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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
 
Upvote 0
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:
Upvote 0
Solution

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top