How to Use Excel Formula Not to Exceed a Certain Value

In this article, we will use different methods like Data Validation, MAX, MIN, RANDBETWEEN, and IF functions to set a value that should not be exceeded.

We’ll use the following sample dataset to demonstrate these methods, which contains Shirt Brand Name in Column B, Size in Column C, and Price in Column D.

Dataset to Use Excel Formula Not to Exceed a Certain Value


Method 1 – Using a Data Validation Value Range

Data Validation is a powerful tool to set a limit to a cell or a range. For example, if we want to record the age of customers in a cell range, we can set the Data Validation to accept numerical values only, set upper and lower limits for a particular type of data, and return a message to the user about why the data was not accepted and how to resolve the issue.

Steps:

  • Select the range Size.
  • Click the Data Tab.
  • Click Data Tools.
  • Select Data Validation from the drop-down list.
  • Then select Data Validation from the Data Validation drop-down list.

Using Data Validation option to Use Excel Formula Not to Exceed a Certain Value

The Data Validation window will pop up on the screen.

  • Click the Settings tab.
  • Select Whole Number (under Validation Criteria Allow).
  • Select between (under Data).
  • Enter 100 (as a Minimum).
  • Enter 200 (as a Maximum).
  • Click OK.

Data validation dialog box to Use Excel Formula Not to Exceed a Certain Value

  • Click the Error Alert tab.
  • Select Warning (from the Style drop-down menu).
  • Select Out_of_Range (as a Title).
  • Enter “Please Enter a value between 100200” (as an Error message).

Setting Error Alert to Use Excel Formula Not to Exceed a Certain Value

Now, if you enter a value outside the accepted range (100 to 200), our warning message will display.

Warning is working to Use Excel Formula Not to Exceed a Certain Value

  • Enter values into the other cells in column D manually.

Only values within the range 100 to 200 will be accepted.

Result to Use Excel Formula Not to Exceed a Certain Value


Method 2 – Using a Data Validation Custom Formula

Data Validation offers custom formulas to maintain a certain range of values. Let’s use the AND function (which combines two or more arguments and results) to insert two arguments into our Validation Criteria – minimum and maximum.

Steps:

  • As in the previous method, select the range Size > go to Data Tab > Data Validation options.

The Data Validation window will pop up on the screen.

  • In the Settings tab, select Custom under Allow.
  • Enter the following formula under Formula:

=AND(D5>=100,D5<=200)

Inserting Formula to Use Excel Formula Not to Exceed a Certain Value

  • Click OK,
  • Start inserting values manually in column D.

Only values within the range will be accepted.

Result to Use Excel Formula Not to Exceed a Certain Value


Method 3 – Using the MAX Function

The MAX function returns the largest value in a given list of arguments.

Steps:

  • Arrange the dataset as per the below image.

  • Enter the following formula in cell E5:
=MAX(0.8*D5,90)

Inserting Formula to Use Excel Formula Not to Exceed a Certain Value

  • Press Enter to return the result.
  • Drag the Fill Handle down to apply the formula to the other cells in column E.

  • The Maximum Prices will be set by our formula (the greater of 90 and 80% of the Price).


Method 4 – Using the MIN Function

The MIN function is generally used to extract the lowest or smallest value from a range of cells containing numerical data only.

Steps:

  • Arrange the dataset like the below image.

  • Insert the following formula in cell E5:
=MIN(0.8*D5,140)

Inserting Formula to Use Excel Formula Not to Exceed a Certain Value

  • Press Enter to return the result.
  • Drag the Fill Handle down to apply the formula in the rest of the cells in the column.

Minimum Prices are set (the lower of 140 and 80% of the Price).


Method 5 – Using the IF Function

We can also the IF function to restrict entries to our desired range. The IF function applies a set of conditions, returning one result if TRUE and another if FALSE.

Steps:

  • Arrange the dataset like the below image.

  • Insert the following formula in cell F5:
=IF(D5<100,0,IF(D5>200,0,D5))

Inserting Formula to Use Excel Formula Not to Exceed a Certain Value

  • Press Enter.
  • Drag the Fill Handle down to apply the formula to the other cells in the column.

The results are as follows:

Final Result After Inserting Formula to Use Excel Formula Not to Exceed a Certain Value


Method 6 – Using the RANDBETWEEN Function

The RANDBETWEEN function can be used to randomly generate values between a maximum and minimum value, Say we want random sizes of our shirts between 22 and 30.

Steps:

  • Arrange the dataset like the below image.

  • Insert the following formula in cell C8:
=RANDBETWEEN($C$5,$C$4)

Inserting Formula to Use Excel Formula Not to Exceed a Certain Value

  • Press Enter to return the result.
  • Drag the Fill Handle down to apply the formula to the rest of the cells in the column.

The results are as follows:

Showing Result After Inserting Formula to Use Excel Formula Not to Exceed a Certain Value


 

Download Practice Workbook


Related Articles


<< Go Back to Data Validation in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Zehad Rian Jim
Zehad Rian Jim

Zehad Rian Jim is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He's good with Microsoft Office and has written more than 80 helpful articles for ExcelDemy in the last year. Now, he makes fun and easy-to-follow Excel tutorials for YouTube as part of the ExcelDemy Video project. Zehad loves figuring out Excel problems, and his passion for learning new things in Excel shines through in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo