How to clamp (limit) a value between a minimum and maximum
✓ Verified in LibreOffice 25.8.7.3Force a number to stay within a range - anything below the floor becomes the floor, anything above the cap becomes the cap.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =MIN(MAX(A2,0),100) | MAX raises up to the floor; MIN caps at the ceiling. |
| Google Sheets | =MIN(MAX(A2,0),100) | Identical. |
| LibreOffice Calc | =MIN(MAX(A2,0),100) | Identical. |
How it works
MAX(A2,0) makes sure the value is at least 0; MIN(...,100) makes sure it's at most 100. A value of 150 is pulled down to the cap of 100. A value of -5 would be raised to 0, and anything already between 0 and 100 passes through unchanged.
Verified, not just documented
We ran =MIN(MAX(A2,0),100) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 100 — exactly the expected result. Every formula here is confirmed by actually executing it.