Limiting a Calculated Value to a Range

Written by Allen Wyatt (last updated April 12, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


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 Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Saving Documents Faster

If you are using Word versions 97 through 2003, there's a setting you can make that will allow you to save your documents ...

Discover More

Changing Your Name

One of the many pieces of information that Excel keeps track of is your name. If you want to change your name for Excel's ...

Discover More

Accept All Changes by a Particular Reviewer

The Track Changes feature in Word allows you and other editors to easily collaborate on the development of a document. If ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Incrementing Numeric Portions of Serial Numbers

If you use serial numbers that include both letters and numbers, you might wonder how you can increment the numeric ...

Discover More

Counting Alphabetic Characters in a String

Need to find out how many times a certain letter appears in a text string? It's easy to do if you rely on the SUBSTITUTE ...

Discover More

Indirectly Referencing a Cell on a Different Worksheet

Excel includes the powerful INDIRECT function which can be used to assemble references to other cells in your workbook. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.