How to Enter an Investment Optimization Model in Excel Solver
Question details
The user wants to know how to structure and input an investment optimization problem into the Solver add-in.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Building a financial model to optimize investments by balancing expected returns, risk, and portfolio constraints.
- Observed behavior
- Needs step-by-step guidance on defining decision variable cells, objective functions, and adding constraints in Solver.
Ensure the Solver add-in is enabled in your spreadsheet software before starting. You should also have your historical investment data, expected returns, and covariance matrix prepared in the worksheet.
Setting Up and Running the Investment Optimization in Solver
Follow these steps to define your decision variables, objective function, and constraints to successfully run the optimization.
To build an effective investment optimization model, you must translate your financial goals into mathematical formulas that Solver can process. This involves defining what you can change (asset weights), what you want to achieve (maximize return or minimize risk), and the limits you must adhere to.
Allocate specific cells for your investment weights (e.g., how much capital goes into each asset). These will be set as the changing 'Variable Cells' in Solver.
Create a formula that calculates your primary goal. This could be a SUMPRODUCT formula maximizing expected return, or a matrix calculation (using MMULT) to determine portfolio variance to minimize risk.
Add formulas in your sheet to represent limits. For example, use a SUM formula to ensure total investment weights equal 100% (1.0). You may also want to set minimum or maximum limits for individual asset cells.
Navigate to the Data tab and click 'Solver'. Set the 'Set Objective' box to your objective function cell, choose 'Max' or 'Min', input your decision variable cells into 'By Changing Variable Cells', and add your constraints. Finally, click 'Solve' to find the optimal allocation.

Use the Solver Tool in WPS Spreadsheet for Investment Optimization
WPS Spreadsheet includes a built-in Solver tool that seamlessly handles investment optimization models, linear programming, and complex financial forecasting without requiring additional downloads.
- 1. Enable Solver in WPS: Open WPS Spreadsheet, go to the 'Data' tab, and click on 'Solver'. If it's not visible, go to Menu > Options > Add-Ins to enable it.
- 2. Input Your Model Data: Enter your expected returns, asset weights, and covariance matrix into the worksheet, just as you would in Excel.
- 3. Set Solver Parameters: Define your Target Cell (objective), Variable Cells (asset weights), and add constraints (e.g., total weight = 100%).
- 4. Solve the Model: Choose your solving method and click 'Solve' to generate the optimal investment portfolio.

Frequently Asked Questions
Why is the Solver option missing from my Data tab?
By default, the Solver add-in is not activated. You need to enable it by going to File > Options > Add-ins, selecting 'Excel Add-ins' at the bottom, clicking 'Go', and checking the 'Solver Add-in' box.
How do I handle risk and covariance in the Solver model?
To account for risk, you must create a covariance matrix of your assets and use the MMULT function to calculate the overall portfolio variance. Set this variance cell as your objective to minimize, or use it within a constraint.
What solving method should I choose for investment portfolios?
For minimizing variance or standard deviation (which involves squaring terms), use the GRG Nonlinear engine. If your model is strictly linear (e.g., just maximizing returns without risk constraints), the Simplex LP method is more efficient.




