Setting an Upper Threshold for a Cell

Written by Allen Wyatt (last updated May 31, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


2

Jacob wants to format a cell so that when he enters a value, if it is above a predetermined threshold, it will show the threshold. For example, if the cell is formatted so that 50 is the highest number he can enter, should he enter 60, the cell will display 50.

If all you want to do is to modify what is displayed in the cell, you could create a simple custom format in this manner:

  1. Select the cell you want to affect. (This would be the cell in which you want nothing larger than the threshold displayed.)
  2. Display the Home tab of the ribbon.
  3. Click the small icon at the lower-right corner of the Number group. Excel displays the Format Cells dialog box.
  4. Make sure the Number tab is selected. (See Figure 1.)
  5. Figure 1. The Number tab of the Format Cells dialog box.

  6. In the Category list, at the left side of the dialog box, choose Custom.
  7. In the Type box, at the left of the dialog box, enter the following format: [Red][>50]"50";0
  8. Click on OK.

This approach doesn't modify what is stored in the cell; it simply changes what is displayed in the cell—the largest value it displays is 50, and it will display it in red. The fact that the over-threshold value is still stored in the cell may cause other problems for your worksheet, which may be more trouble than it is worth.

Jacob's situation is typically handled through the use of the Data Validation capabilities of Excel. You would simply set up a rule that indicates what to do if the value in the cell is outside of whatever bounds you want:

  1. Select the cell in which you want to set your threshold.
  2. Display the Data tab of the ribbon.
  3. In the Data Tools group, click the Data Validation tool. (The Data Validation tool is in the Data Validation group if you are using Excel 2007 or Excel 2010.) Excel displays the Data Validation dialog box. (See Figure 2.)
  4. Figure 2. The Settings tab of the Data Validation dialog box.

  5. Using the Allow drop-down list, choose Whole Number. Excel changes the controls available in the dialog box.
  6. Using the Data drop-down list, selected the Less Than or Equal To option.
  7. Enter in the Maximum box the value 50.
  8. On the other tabs of the dialog box, enter an input message and an error message, if desired.
  9. Click OK.

This ensures that someone can only enter a value between 0 and 50 in the cell. If they try to enter a value outside of this range, then whatever error message you specified (step 7) is displayed and the user has the chance to enter a different value.

This approach may not fulfill Jacob's desires, however, as he would simply like to have the value in the cell be changed to the threshold value. In this case, you would need to resort to using a macro. Here's a simple one that could be used:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B7")) Is Nothing Then
        If Target > 50 Then Target = 50
    End If
End Sub

This macro is implemented as an event handler. To use it, right-click on the worksheet's tab and choose Code from the resulting Context Menu. The above macro then can be pasted into that code window. You will also need to modify which cell it is that you want the macro to pay attention to; as written, it only kicks into action if you try to enter the value into cell B7.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13638) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, 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

Word Count for a Section

Dynamic word counts for your entire document are easy to get when you use using fields. There is no built-in method to ...

Discover More

Automatic Row Height For Merged Cells with Text Wrap

When you have text wrap turned on in a cell, Excel expands the height of the row as you add more text to the cell. When ...

Discover More

Using Copilot

It seems that every company is in a race to add AI capabilities to their products. Microsoft is no exception, and that is ...

Discover More

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!

More ExcelTips (ribbon)

Getting Help when Entering Functions

Need a quick memory jog when entering a worksheet function? Here's a shortcut that will be invaluable.

Discover More

Typing Check Marks into Excel

Need to enter a check mark into a cell? There are a number of ways you can get the desired character, depending on the ...

Discover More

Stopping Feet and Inches from Converting to Dates

When pasting information into a worksheet, Excel tries to helpfully convert that information. This can cause undesired ...

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 3 + 9?

2025-06-01 09:53:28

J. Woolley

@Tomek
Good catch. How would you modify the setting to insure a 0 to 50 restriction?


2025-05-31 21:39:08

Tomek

Re: This ensures that someone can only enter a value between 0 and 50 in the cell. If they try to enter a value outside of this range, then whatever error message you specified (step 7) is displayed and the user has the chance to enter a different value.

Actually, with the setting suggested in the tip, the user can enter also negative numbers.


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.