Put Value From Solver In Memory

J

Jonas

Is it possible to put the value from Excel's solver function into
memory rather than a cell in Excel? My intention is to use solver to
get a value and use that value in another function. However, the fist
value that I get from solver might not work with my function. That is
why I want to vary the initial value with a loop and be able to save
the value from solver in memory rather than in Excel. Below is the
code that I have. It writes the value from solver to a cell in Excel.

Sub Macro2solver()

solverreset

SolverOk SetCell:="$E$29", MaxMinVal:=3, ValueOf:="0",
ByChange:="$E$26"
SolverSolve UserFinish:=True
SolverFinish KeepFinal:=1

End Sub
 
G

Guest

A good place to store stuff like this is in a static array. If we insert:

Dim memory(100) as Double
Dim Cntr as Integer

At the very top of the module (above the subs ), then in the subs we can put:

Cntr=Cntr + 1
memory(Cntr) = Range("E26").value

This will keep a "history" of the solutions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top