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

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
you ask for Subtract n from min value and then remainder of n from max value

what is the range for min value? Cols B, C & D?
same question for max value? what is the range for the max?

and how do you get to the 69 in F4
 
Upvote 0
So, the min and max are in cells C & D, B is the value to subtract.

Looking at row 4.

C4 is the max and D4 is the min. It should subtract 'n' (30) from D4 first as it is the min value and equal 69 and as nothing is remaining in 'n', C4 remains at 100.

Does that make sense?
 
Upvote 0
right, try this


Excel 2013/2016
ABCDE
1(A1)(B1) n(C1) a(D1) b
2(A2)30202515
3(A33017141
4(A4)3010099100
Sheet1
Cell Formulas
RangeFormula
E2=MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0)
 
Upvote 0
Sorry AlanY, that's not it. E4 should be 100 and F4 69.

Sorry, just realised my formula had been clipped in post 1. E4 and F4 have =IF(C4=D4,C4-(B4/2),IF(C4<D4,MIN(SUM(C4:4)-B,0),MAX(SUM(C4:D4)-B4,0)))
 
Last edited:
Upvote 0
E4 is 100! is that what you're after for F4?


Excel 2013/2016
ABCDEF
1(A1)(B1) n(C1) a(D1) b
2(A2)30202515-10
3(A33017141-16
4(A4)301009910069
Sheet1
Cell Formulas
RangeFormula
E2=MAX(C2:D2)+MIN(MIN(C2:D2)-B2,0)
F2=MIN(C2:D2)-B2
 
Upvote 0
Sorry AlanY, just realised my original post was clipped in the formula. My less than keeps getting clipped.

Formula in E4 and F4 is
Code:
=(C4=D4,C4-(B4/2),IF(C4 < D4,MIN(SUM(C4:D4)-B4,0),MAX(SUM(C4:D4)-B4,0)))
<d4,min(sum(c4:d4)-b4,0),max(sum(c4:d4)-b4,0)))[ code]

The idea is, it subtracts B4 from the lowest of the 2 values in C4 or D4 and if anything remains of B4, subtract is from the max in C4 or D4 and both reduce to a minimum of zero.</d4,min(sum(c4:d4)-b4,0),max(sum(c4:d4)-b4,0)))[>
 
Last edited:
Upvote 0
you need to put a space before and after the <, > etc for them to show up properly
 
Upvote 0
Sorry AlanY, just realised my original post was clipped in the formula. My less than keeps getting clipped.

Formula in E4 and F4 is
Code:
=(C4=D4,C4-(B4/2),IF(C4 < D4,MIN(SUM(C4:D4)-B4,0),MAX(SUM(C4:D4)-B4,0)))
<d4,min(sum(c4:d4)-b4,0),max(sum(c4:d4)-b4,0)))[ code]

The idea is, it subtracts B4 from the lowest of the 2 values in C4 or D4 and if anything remains of B4, subtract is from the max in C4 or D4 and both reduce to a minimum of zero.</d4,min(sum(c4:d4)-b4,0),max(sum(c4:d4)-b4,0)))[>

but, isn't that's exactly the formula in Col E doing?

=MAX(C4:D4)+MIN(MIN(C4:D4)-B4,0)
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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