question

%3CLINGO-SUB%20id%3D%22lingo-sub-1934227%22%20slang%3D%22en-US%22%3Equestion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934227%22%20slang%3D%22en-US%22%3E%3CP%3ECan%20I%20put%20a%20minimum%20and%20a%20maximum%20number%2C%20that%20a%20cell%20with%20a%20formula%2C%20can%20have%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1934227%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1934245%22%20slang%3D%22en-US%22%3ERe%3A%20question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934245%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F882630%22%20target%3D%22_blank%22%3E%40lfox2%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20you%20will%20need%20to%20use%20MIN()%20and%20MAX()%20formula.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22adversi_0-1606400348512.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F236265iB174AC4896DC04A2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22adversi_0-1606400348512.png%22%20alt%3D%22adversi_0-1606400348512.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1934251%22%20slang%3D%22en-US%22%3ERe%3A%20question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934251%22%20slang%3D%22en-US%22%3EHey.%20Yes%20it's%20possible%20to%20do%20that%20!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1934338%22%20slang%3D%22en-US%22%3ERe%3A%20question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934338%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F882630%22%20target%3D%22_blank%22%3E%40lfox2%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20not%20like%20data%20validation.%26nbsp%3B%20If%20the%20result%20of%20the%20calculation%20is%20a%20scalar%20value%20then%20the%20MEDIAN%20function%20can%20be%20used%20to%20place%20upper%20and%20lower%20bounds%20of%20the%20result%20returned%20by%20the%20formula.%26nbsp%3B%20So%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20value*(1%2Brate)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ebecomes%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%20MEDIAN(%20min%2C%20max%2C%20value*(1%2Brate)%20)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%2C%20like%20me%2C%20you%20always%20use%20array%20formulas%2C%20life%20become%20more%20difficult%20because%20the%20aggregation%20functions%20such%20as%20MIN%2C%20MAX%2C%20SUM%20aggregate%20entire%20array%20rather%20than%20value%20by%20value.%26nbsp%3B%20In%20that%20case%20the%20formula%20might%20need%20to%20be%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3D%20%20LET(%0A%20%20%20result%2C%20array*(1%2Brate)%2C%0A%20%20%20IFS(result%26gt%3Bmax%2C%20max%2C%20%0A%20%20%20%20%20%20%20result%3CMIN%3E%3C%2FMIN%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Can I put a minimum and a maximum number, that a cell with a formula, can have?

6 Replies

@lfox2 

Yes, you will need to use MIN() and MAX() formula.

adversi_0-1606400348512.png

 

Hey. Yes it's possible to do that !

@lfox2 

It is not like data validation.  If the result of the calculation is a scalar value then the MEDIAN function can be used to place upper and lower bounds of the result returned by the formula.  So

= value*(1+rate)

becomes

= MEDIAN( min, max, value*(1+rate) )

 

If, like me, you always use array formulas, life become more difficult because the aggregation functions such as MIN, MAX, SUM aggregate entire array rather than value by value.  In that case the formula might need to be

 

=  LET(
   result, array*(1+rate),
   IFS(result>max, max, 
       result<min, min, 
       1, result))

 

 

 

@luse fox2 

use if-then-else logic

If < m then whatever or if < n then whatever else formula

@lfox2   Learning to provide concrete examples will go a long way toward getting applicable answers.

 

Suppose the original formula is =SUM(A1:A100), and you want the result to be no less than 10 and no more than 100.  You could write:

 

=MAX(10, MIN(100, SUM(A1:A100))

@lfox2 

Hi,

You may apply Custom Data validation to the cell or range where you want to create the formula with upper and lower limits. To do that, 

Select the destination range

Go to the Data Tab and click on data Validation (Shortcut is Alt , D ,L)

Under "Allow" select ► "Custom"

Under Data ► Select Between

Type the Min and Max values and hit OK

 

nabilmourad_0-1606436506099.png

If the result of the function violates the Upper or lower limit ► you get an error message.
Please Note that You cannot create a Formula/ Function in a cell then copy it because copying overwrites the Data Validation.
You can create a very simple code to prevent overwriting  the Data validation, here is a link:
https://www.youtube.com/watch?v=9JhCT6VMzBQ 
Hope that helps

Good Luck
Nabil Mourad

This is a Bite-Size Excel Tutorial Series targeting anyone on the globe who uses Excel, since I broke the barrier of language and I explain the topic fully i...