Subtract n from min value and then remainder of n from max value

MrSheen

New Member
Joined
Jun 26, 2014
Messages
11
As the title says, I want to subtract n from min value first and then the remainder of n from the max value. I thought I had it cracked until one of the values exceeds n.

My formula is =IF(C4=D4,C4-(B/2),IF(C4<D4,MIN(SUM(C4:D4)-B4,0),MAX(SUM(C4:D4)-B4,0))) for bot AA and BB.
<d4,min(sum(c4:d4)-b4,),max(sum(c4:d4)-b4,0)))

The expected result in E4 (AA) should be 100 and F4 (BB) should be 69 but as you can see it falls over. Can anyone make a suggestion?

(A1)(B1) n
(C1) a
(D1) b
(E1) aa
(F1) bb
(A2)
30
20
25
0
15
(A3
30
17
14
1
0
(A4)
30
100
99
169 (Exp 100)
0 (Exp 69)

<tbody>
</tbody>
</d4,min(sum(c4:d4)-b4,),max(sum(c4:d4)-b4,0)))
 
Hi AlanY,

Sorry, my brain is switched off, I blame the birth of my twin boys!

Solution in the end was this.

E2 =IF(IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))) < 0,0,IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))))
F2 =
IF(IF(C2=D2,C2-(B2/2),IF(D2 < C2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))) < 0,0,IF(C2=D2,C2-(B2/2),IF(D2 < C2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))))
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi AlanY,

Sorry, my brain is switched off, I blame the birth of my twin boys!

Solution in the end was this.

E2 =IF(IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))) < 0,0,IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))))
F2 =
IF(IF(C2=D2,C2-(B2/2),IF(D2 < C2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))) < 0,0,IF(C2=D2,C2-(B2/2),IF(D2 < C2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))))

your formula in E2 yielded 0, 30 take away the min of (20, 25) equal to 10, and minus by the max of (20, 25). shouldn't that equal to 15?
i'm still not sure the criteria for F2 etc


Excel 2013/2016
ABCDEF
1nabaabb
2302025015
330171410
4301009910069
Sheet1
Cell Formulas
RangeFormula
E2=IF(IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))) < 0,0,IF(C2=D2,C2-(B2/2),IF(C2 < D2,MIN(C2:D2)-B2,MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0))))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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