Calculation Issues

Use Excel Solver to Return Whole Number Values

Huda QurayshiHuda Qurayshi Nov 22, 2026 868 views

Question details

The user needs Excel Solver to return integer or whole-number values in the variable cells.

Use Excel Solver to Return Whole Number Values
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.
Before you start

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.

Solution 1Recommended

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.

1
Open Solver

In Excel, select Data > Solver and check the range in By Changing Variable Cells.

2
Add the constraint

Under Subject to the Constraints, select Add. In Cell Reference, enter or select the variable cells that must be integers.

3
Select the integer type

Open the constraint relation menu, select int, and click OK. To change an existing constraint instead, select it and click Change.

4
Require nonnegative values if needed

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.

5
Solve the model

Click Solve, then select Keep Solver Solution in the results dialog if the solution meets your needs.

Add an integer constraint to the Excel Solver variable cells
Integers can be negative: The int constraint allows negative integers. Add a nonnegative constraint when values must be zero or greater.
Free Microsoft Office alternative

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.

Open and edit Microsoft Excel XLSX and XLS spreadsheets.Work with spreadsheet formulas and numerical data in a familiar interface.Use a free, lightweight office suite for everyday documents and spreadsheets.Move existing Office files into a familiar workspace.
microsoft office alternative - wps office

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.