# Subtracting if drop down box says "Yes"

#### niccc

##### New Member
Hi all,

I would like some help with an excel spreadsheet I am creating to keep track of my overtime at work.

As seen in the attached file, Column D is the overtime that I worked on that day. Column E is a dropdown box (Yes,No) which identifies if I have used those overtime hours (Eg. On X day, I decided to finish work early and use my overtime hours from the previous day. In this instance, I would be selecting "Yes").

Cell D7 is equal to the total amount of overtime worked. I currently have =SUM(D3:D5) as the formula.

Cell D8 would be the actual total. Basically subtracting any overtime hours used.

I would like to know what formula I can use so that every time a cell in column E says "Yes", it would subtract the total amount of overtime in cell D7 and create a new value in D8 (actual total).

I tried to use the formula =IF(E3="Yes",D7-D3,D7) in cell D8, however, it only works for that specific row and not the ones below/after.

Thank you

#### Attachments

33.1 KB · Views: 14

### Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

#### jtakw

##### Well-known Member
Hi,

Incorporate SUMIF:

Book3.xlsx
ABCDE
1
2
32No
410Yes
52Yes
6
714
82
Sheet990
Cell Formulas
RangeFormula
D7D7=SUM(D3:D5)
D8D8=D7-SUMIF(E3:E5,"Yes",D3:D5)

#### niccc

##### New Member
Hi,

Incorporate SUMIF:

Book3.xlsx
ABCDE
1
2
32No
410Yes
52Yes
6
714
82
Sheet990
Cell Formulas
RangeFormula
D7D7=SUM(D3:D5)
D8D8=D7-SUMIF(E3:E5,"Yes",D3:D5)
Thank you so much

#### jtakw

##### Well-known Member
You're welcome, thanks for the feedback.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,167,298
Messages
5,853,136
Members
431,549
Latest member
NnAa

### 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.

### Which adblocker are you using?

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

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