Excel solver macro help.
November 1, 2009 11:24 AM Subscribe
I have a column of around 100 equations that can only be solved with solver in Excel.
Is there any way to create a macro for this purpose. The layout of the spreadsheet given below.
........................ |W1|W2|W3| SD
E(Rp1) "|............| 0 | 0 _ |_1|_0
We are seeking to minimize SD by changing W1, W2 and W3, under the constraint E(Rp1)= a certain number: which starts at say 2 and increases by .1 till 20. The question is whether macros can be written for add-ins?
All that weird formatting was to make sure the cells would line up.
posted by Lucubrator to computers & internet (3 answers total) 1 user marked this as a favorite
A macro to run the solver, to set D7 to value of 0 by changing cell D3:
Sub Macro1() SolverOk SetCell:="$D$7", MaxMinVal:=3, ValueOf:="0", ByChange:="$D$3" SolverSolve UserFinish:=True SolverFinish KeepFinal:=1 End SubI've tested this in Excel 97 and it works after I add a 'reference' to solver.xla, from the 'tools' menu in the VB editor.If you're using a newer version of Excel, I suggest you look at this documentation of the SolverOK function.
If I've misread your question and this isn't what you wanted to know about, you might want to clarify your question :)
posted by Mike1024 at 2:03 PM on November 1, 2009