Use Excel Solver to Return Whole Number Values
Question details
The user needs Excel Solver to return integer or whole-number values in the variable cells.

- Product
- Microsoft Excel Solver
- Device & OS
- not provided
- Scenario
- An optimization model uses Solver to calculate values for selected variable cells.
- Observed behavior
- Solver returns decimal values even though the variable cells must contain integers or whole numbers.
Identify the cells listed in Solver's By Changing Variable Cells field. If Solver is not visible on the Data tab, enable the Solver Add-in first.
Add an integer constraint to the Excel Solver variable cells
Use an integer constraint when Solver must return values without decimal portions in selected variable cells.
In Excel, select Data > Solver and check the range in By Changing Variable Cells.
Under Subject to the Constraints, select Add. In Cell Reference, enter or select the variable cells that must be integers.
Open the constraint relation menu, select int, and click OK. To change an existing constraint instead, select it and click Change.
For whole numbers including zero, check Make Unconstrained Variables Non-Negative, or add a constraint requiring the relevant cells to be greater than or equal to 0.
Click Solve, then select Keep Solver Solution in the results dialog if the solution meets your needs.

Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Excel formats, making it easy to move everyday spreadsheet work to WPS. It does not change the Solver settings in Microsoft Excel.

Frequently Asked Questions
Where do I find Solver in Excel?
Look for Solver on the Data tab. In Excel for Windows, you can enable it through File > Options > Add-ins, then select Excel Add-ins under Manage, click Go, and check Solver Add-in.
How do I stop Solver from returning negative integers?
In Solver Parameters, add a constraint requiring the relevant variable cells to be greater than or equal to 0, in addition to the int constraint. You can also check Make Unconstrained Variables Non-Negative when appropriate.
Why does Solver still return decimals after I add an integer constraint?
Check that the int constraint refers to the correct variable cells. Also open Solver Options and make sure Ignore Integer Constraints is not selected, then run Solver again.
Can I just format the variable cells to show no decimal places?
No. Changing the number format only changes how values appear; it does not make the underlying values integers. Add an int constraint in Solver Parameters instead.




