# Formula to add and then multiply only if result of sum is a positive number?

#### nene0713

##### New Member
I'm working with a time sheet where I need to calculate and track actual hours worked, comp hours earned, comp hours accumulated, and comp hours used. I have formulas to do this, but we are going to a new system where comp hours worked are earned at a rate of 1.5. I need to add up hours worked for the current week, multiply anything over 40 by 1.5, and add it to the "comp hours bank". But if a person uses comp hours instead of earns them, those just need to be subtracted out of the bank.

Is there a way to do this formula all in the same cell or do I need to create a reference cell?

I have a screenshot of my worksheet but I can't figure out how to insert it in this message. I will try and explain below. Where the text is red - those are the cells where I want a formula that will take current hours worked, subtract 40, multiply by 1.5 if it's a positive number, then add to or subtract from whatever was already in the bank.

Example:
 Comp Hours Bank (carried over from previous month) 3 Week 1 hours worked 50 New comp bank total (week 1 hours - 40, multiplied by 1.5, added to 3 hours already in bank) 18 Week 2 hours worked 32 New comp bank total (8 hours comp time used, subtracted from bank) 10

<tbody>
</tbody>

Thank you for any help!!

### Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

#### JLGWhiz

##### Well-known Member
i think this would work.
Assume RowsCells A1:A5
In A3
Code:
``=If(A2>40,A1+((A2-40)*1.5),A1+(A2-40))``
In A5
Code:
``=If(A4>40,A3+((A4-40)*1.5),A3+(A4-40))``

Last edited:

Replies
1
Views
122
Replies
2
Views
100
Replies
2
Views
110
Replies
3
Views
118
Replies
14
Views
156

Threads
1,191,383
Messages
5,986,305
Members
440,017
Latest member
vasanrajeswaran

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

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