Conditional Format True and Wrong Calculation

Emre06

New Member
Joined
Sep 27, 2023
Messages
19
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Greetings. I need help with the conditional format of calculations. Time formats are in 24 hours (hh:mm). How can I conditional format wrong calculations (Third row calculated wrongly) and true calculations (1,2,4th row true). Thank you for your time. ( For an example just wanted to 3rd column [Duration] Green if correct, Red if wrong calculation)

Kitap1
ABC
1DepartureArrivalDuration
211:0013:0002:00
323:1001:0001:50
410:5012:5003:00
508:0010:0002:00
Sayfa1
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I don't have a different column for calculation. I tried this code but its not working for all "Conditional format" C:C -> Equal ->
Excel Formula:
=(B:B-A:A)
 
Upvote 0
I think your formatting is the main issue. In row 3, you cannot subtract A3 from B3 and get a number that can be formatted as a time because it is a negative number. The A3 and B3 values must be a date and time for the difference to be calculated correctly. B3 would be the next day.
Book1
ABC
7DepartureArrivalDuration
811:0013:002:00
923:101:001:50
1010:5012:502:00
118:0010:002:00
Sheet1
Cell Formulas
RangeFormula
C8:C11C8=B8-A8

Hope that helps,

Doug
 
Upvote 0
All three rows recieving information from other sources, manually entering all the rows is not practical.
Any other solutions?
 
Upvote 0
Could you put a formula in your duration column that correctly calculates the duration? Something like this...
Excel Formula:
=IF(A2<B2,B2-A2,24-A2+B2)
Hope that helps,

Doug
 
Upvote 0
Could you put a formula in your duration column that correctly calculates the duration? Something like this...
Excel Formula:
=IF(A2<B2,B2-A2,24-A2+B2)
Hope that helps,

Doug
Thank you it works. But data to 3rd column automatically added from Microsoft forms. it will erase formula, because of it I am trying to verify calculations without touching column and row.
 
Upvote 0
An issue with using the formula is the rounding. On the surface, they look the same...
Book1.xlsx
ABCDE
1DepartureArrivalDurationCalculated DurationCheck
211:0013:002:002:00FALSE
323:101:001:501:50FALSE
410:5012:503:002:00FALSE
58:0010:002:002:00FALSE
Sheet3
Cell Formulas
RangeFormula
D2:D5D2=IF(B2<A2, B2+1-A2, B2-A2)
E2:E5E2=D2=C2


But they're in fact different.
Book1.xlsx
ABCDE
1DepartureArrivalDurationCalculated DurationCheck
211:0013:000.08333333333333330000.0833333333333340000FALSE
323:101:000.07638888888888890000.0763888888888887000FALSE
410:5012:500.12500000000000000000.0833333333333330000FALSE
58:0010:000.08333333333333330000.0833333333333340000FALSE
Sheet3
Cell Formulas
RangeFormula
D2:D5D2=IF(B2<A2, B2+1-A2, B2-A2)
E2:E5E2=D2=C2
 
Upvote 0
@BigBeachBananas Thank you very much for the detailed examination. Do you have any recommendations on how we can solve this?
 
Upvote 0
Maybe round both to 10 decimal places or however many you feel comfortable.

Book1.xlsx
ABC
1DepartureArrivalDuration
211:0013:002:00
323:101:001:50
410:5012:503:00
58:0010:002:00
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:C5Expression=ROUND(MOD(B2-A2,1),10)<>ROUND(C2,10)textNO
C2:C5Expression=ROUND(MOD(B2-A2,1),10)=ROUND(C2,10)textNO
 
Upvote 1
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

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