Written by Allen Wyatt (last updated June 7, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
Om has a formula in a cell that can return just about any value. However, he wants to limit what is returned to make sure it is in the range of 10 to 100. If the formula would return something below 10, then 10 is returned. If it would normally return something over 100, then 100 is returned. Otherwise, if the value is within this range, the actual results are returned.
Perhaps the easiest way to handle a situation like this is to use the IF function. Let's say, for instance, that your value is in cell A1. In this case, you could use a formula like this in cell B1:
=IF(A1<10,10,IF(A1>100,100,A1))
This formula looks at the value in cell A1. If it is less than 10, then the value 10 is displayed in the cell. However, if the value is 10 or greater, then the next IF function is invoked. This one checks to see if the value in A1 is greater than 100. If it is, then the value 100 is displayed in the cell. If the value is not greater than 100, then the value in A1 is displayed in the cell.
It gets a bit more complex if you want the limitation to be in the same cell as the original formula (A1). Essentially, you would need to use the above formula and everywhere that you see "A1" in the formula, you would need to replace with the formula that is contained in cell A1.
For instance, let's say you have a simple formula in cell A1, such as the following:
=(K7+2)*3.7/12
You would substitute that formula in the formula that uses the IF function, in this manner:
=IF(((K7+2)*3.7/12)<10,10,IF(((K7+2)*3.7/12)>100,100,((K7+2)*3.7/12)))
Note that I took the A1 formula and placed it within parentheses. The formula appears 3 times within the longer formula because there were 3 occurrences of A1 in that original formula. This process is often referred to as "wrapping your formula in an IF function" and is a very common task in Excel. Depending on the length of the formula you are wrapping, the resulting formula can be quite long and complex.
Another easy way to accomplish the same result is to use both the MIN and MAX functions in a formula. Let's say, again, that you still have the same simple formula that you are using. You can wrap that formula in the MIN and MAX functions in this manner:
=MIN(MAX((K7+2)*3.7/12, 10),100)
This construction compares the result of your formula to the value 10 and returns whichever one is larger. This result is then compared against the value 100 and the minimum of those two is returned—very slick and a great use of the MIN and MAX functions.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13657) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
If you need a formula to change spaces to some other character, the SUBSTITUTE function fits the bill. Here's how to use it.
Discover MoreSometimes it is helpful to look at data that is rotated 90 degrees. Excel allows you to use Paste Special to transpose ...
Discover MoreWhen converting between measurement systems, you might want to use two cells for each type of measurement. Make a change ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-06-09 10:15:00
Alex Blakenburg
@J. Woolley - 👍
2025-06-08 10:24:52
J. Woolley
@Alex Blakenburg
Thank you for teaching me about MEDIAN. I didn't know it could be used like MIN/MAX.
2025-06-08 04:23:19
SAndeep
Very useful formulae, Allen
2025-06-07 13:32:19
Kenneth Kast
The approach of repeating the calculation multiple times may become time-expensive, or even impossible, if a UDF is involved. For MS 365 the LET statement allows you to calculate a value once and reuse it at minimal cost. It is probably less efficient than the MAX-MIN solution but can be used in any scenario where a recalculation is required. I think of LET as an inline UDF.
2025-06-07 09:19:22
Alex Blakenburg
This should work too.
=MEDIAN(A1,10,100)
=MEDIAN((K7+2)*3.7/12, 10,100)
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments