How to Limit an Excel Running Total to a Maximum and Minimum
Question details
The user needs to calculate a running inventory balance that adds purchases and subtracts sales, ensuring the final total never exceeds a strict maximum of 10 or falls below a minimum of 0.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking inventory or stock where capacity has a hard ceiling (maximum) and the stock level cannot logically be negative.
- Observed behavior
- The balance needs to be automatically constrained between the values of 0 and 10 using a drag-down formula.
Ensure your inventory data is organized into structured columns, typically containing a 'Previous Balance', a 'Purchases' (additions) column, and a 'Sales' (deductions) column so the formula can calculate correctly row by row.
Use MIN and MAX Functions Combined
This is the most robust and elegant method to set both a hard ceiling (maximum) and floor (minimum) on a calculated value.
By nesting functions, the MIN function first evaluates the sum and 10, returning whichever is smaller to cap the total. Then, the MAX function evaluates that result against 0, returning whichever is larger to prevent negative numbers.
Set up your worksheet so cell A2 holds the previous balance, B2 is the quantity bought, and C2 is the quantity sold.
Click on the cell where you want the new bounded running total (for example, D2) and type =MAX(MIN(A2+B2-C2, 10), 0).
Press Enter to calculate the first row. Click the fill handle (the small square at the bottom-right corner of the cell) and drag it down to apply this bounding formula to the rest of your inventory rows.

Use Nested IF Statements to Limit the Total
An alternative logical approach using IF statements, which may be easier to read for users familiar with basic logical tests.
Track Inventory Caps Seamlessly with WPS Spreadsheet
WPS Spreadsheet fully supports the exact MIN, MAX, and IF functions used in Microsoft Excel. You can quickly set up bounded running totals and complex inventory trackers in WPS Office with a smooth, lightweight interface.
- 1. Launch WPS Spreadsheet: Open WPS Office and create a new Spreadsheet to start tracking your inventory.
- 2. Input Data Columns: Create standard columns for 'Previous Balance' (A), 'Stock In' (B), and 'Stock Out' (C).
- 3. Apply Formula: Type =MAX(MIN(A2+B2-C2,10),0) in your Total column, press Enter, and double-click the fill handle to populate the rest of your sheet.

Frequently Asked Questions
Can I reference a cell for the maximum limit instead of typing '10'?
Yes. Instead of typing 10 in the formula, you can click on a cell containing your maximum limit (e.g., cell E1). Make sure to use absolute references (with dollar signs) so the limit cell reference doesn't shift when you copy the formula down: =MAX(MIN(A2+B2-C2, $E$1), 0).
Why does my running total formula show a #VALUE! error?
This error usually happens if one of the cells you are referencing (A2, B2, or C2) contains text, spaces, or unrecognized characters instead of a number. Check your columns to ensure all inputs, including seemingly blank cells, are formatted strictly as numbers or are truly empty.
How do I only set a maximum limit without a minimum?
If you only want to cap the total at 10 but do not care if it drops into negative numbers, you can remove the MAX portion of the formula. Simply use: =MIN(A2+B2-C2, 10).




