Calculate time passed only if a cell meets specific criteria

angeloudaki

New Member
Joined
Jul 7, 2015
Messages
46
Working out time.

How do I use a column to calculate only if a cell contains specific criteria? e.g. Only calculate difference between start and end time if the category is "Accrued" otherwise use "0"

[TABLE="width: 400"]
<colgroup><col width="80" span="5" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl65, width: 80"]Category[/TD]
[TD="class: xl65, width: 80"]Start[/TD]
[TD="class: xl65, width: 80"]End[/TD]
[TD="class: xl65, width: 80"]Accrued[/TD]
[TD="class: xl65, width: 80"]Used[/TD]
[/TR]
[TR]
[TD="class: xl66"]Accrued[/TD]
[TD="class: xl67"]09:25[/TD]
[TD="class: xl67"]09:40[/TD]
[TD="class: xl68"]00:15[/TD]
[TD="class: xl65"]0[/TD]
[/TR]
[TR]
[TD="class: xl66"]Used[/TD]
[TD="class: xl67"]16:00[/TD]
[TD="class: xl67"]17:00[/TD]
[TD="class: xl65"] 0[/TD]
[TD="class: xl68"]01:00[/TD]
[/TR]
</tbody>[/TABLE]

I tried an 'If' but I can't make it work :(
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

If you table is as shown in OP, D2 formula copied down and across to calculate Both "Accrued" and "Used":


Book1
ABCDE
1CategoryStartEndAccruedUsed
2Accrued9:259:400:150:00
3Used16:0017:000:001:00
Sheet487
Cell Formulas
RangeFormula
D2=IF($A2=D$1,$C2-$B2,0)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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