In C++ I would use boost::clamp
for this. Basically I have some excel function
A1*B2+C3+D4
I want to do constrain it to +/- some number, call it X1
. The obvious way is this:
MAX(-X1, MIN(X1, A1*B2+C3+D4))
But I want to be able to do this:
CLAMP(A1*B2+C3+D4, -X1, X1)
Does this or something similar exist? I'm just curious - obviously the workaround works, it's just ugly.
1. Select the cell with the formula you want to make it constant. 2. In the Formula Bar, put the cursor in the cell which you want to make it constant, then press the F4 key.
This can be done using MEDIAN. MEDIAN picks the middle of the three values, thus effectively restricting the lower and upper limits.
For example say your minimum is 5 and your maximum is 10:
=MEDIAN(5,0,10)
is 5
=MEDIAN(5,7,10)
is 7
=MEDIAN(5,12,10)
is 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With