Emulating Solver with LAMBDA
Introduction
Excel’s Solver is a powerful optimization tool, but some companies impose restrictions on its use. A friend of mine faced this challenge when his client asked him to recreate a financial model he had previously built using Solver, but without Solver, VBA, or enabling iterative calculations. Seeking an alternative, he wondered if Excel’s LAMBDA function could provide a solution.
Recursive LAMBDA functions can solve optimization problems like this dynamically. In this article, we’ll explore APRxNPVλ, a LAMBDA function that leverages recursion to determine the APR that yields the smallest NPV.
Problem Statement
Here is a example of the worksheet needing our attention.
In the above example, we have been tasked to find the effective APR (Annual Percentage Rate) on Bank Interest (Actual/360) which we can do by finding the rate at which the Net Present Value (NPV) of a given set of cash flows and discount factors is 0, or as close as we can get. Traditional methods, such as Solver, can find the APR by iteratively adjusting it to minimize our NPV calculation until any additional adjustments make no changes between iterations. The APRxNPVλ function replicates this process using recursion within Excel’s LAMBDA framework.
How APRxNPVλ Works
1. Initialization
2. Recursive Refinement
Breakdown of the LAMBDA Components
Here is the LAMBDA.
Why Use This Approach?
? No Need for Solver – Works in environments where Solver or add-ins are prohibited.
? Fully Dynamic – Updates automatically when input data changes.
? Embedded in a Single Cell – Eliminates external VBA or add-ins.
Conclusion
LAMBDA can emulate Excel's Solver feature when circumstances prohibit Solver's use.
Table of each iteration's results.
Here is what is produced with each iteration of APRxNPV. It clearly shows how the routine resolves to the smallest NPV until adjustments to APR make no difference.
compliance reporting @ Natixis | spilledgraphics.com
1 天前replacing SOLVER calculations with dynamic spilled results from LAMBDAs would be fantastic. ?? thanks for sharing this Craig. on image below, a practical use case for emulating SOLVER calculations; a Holt-Winters model to explain forecasting. a masterpiece by Kellogg Professor Sudhakar "Sid" Deshmukh
Co-Fondateur at KAJY Partners, AFM, FMVA, MCGAO, MCCA, BIDA
1 天前This is some hard topic you're tackling with LAMBDA. it would be really incredible if you could look at what can be done to replicate data table behavior. The lambda can be called WHATIF: WHATIF(target_cell, input_cell, input_new_value) I'm not sure if that's even possible. But if there is anyone who could make it work, you're most probably one of them! (A big fan of your works btw)