Subtraction by criteria

Status
Not open for further replies.

theboyscout

New Member
Joined
Nov 29, 2012
Messages
26
The below example is an employee who has a previous balance ofleave. If that employee takes time off from work then that time is subtractedfrom his leave. Therefore, used hrs would be deducted from his balance. In the below scenario the employee had 23 days 6 hours and 45 minutes of leave. Hethen used 1 day 6 hours and 46 mins of leave. Therefore, an hour had tocover the shortage in minutes making hours 5, a day had to be used to make up for theshortage of hours, thus making hours 12( 7 + 6 – 1 , used for mins).

So the criteria is as follows:
If Used_Mins > Balance_Mins , subtract 1 from Hours
If Used_Hours > Balance_Hours, add 7 to Balance_Hours –Used_Hours and subtract 1 from Days
Current_Hours should never be 0 if there’s a value > 0 inDays

The logic is 60 minutes = 1 hours, 7 hours = 1 day



[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Days
[/TD]
[TD]Hours
[/TD]
[TD]Mins
[/TD]
[/TR]
[TR]
[TD]Balance
[/TD]
[TD]23
[/TD]
[TD]6
[/TD]
[TD]45
[/TD]
[/TR]
[TR]
[TD]Used
[/TD]
[TD]1
[/TD]
[TD]6
[/TD]
[TD]46
[/TD]
[/TR]
[TR]
[TD]Current
[/TD]
[TD]21
[/TD]
[TD]6
[/TD]
[TD]59
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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