Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Solver-Macro loop

Status
Not open for further replies.

XLnew

Computer
Dec 21, 2008
12
0
0
US
I have a macro on my worksheet (this is acutualy a button, but I have found which macro this is running).
Say this macro is "xyz" which gives me a result on cell A1. The macro uses B1 as an input to compute A1.

That is, the macro is excecutable with the following piece of code:

Application.Run "mybook.xls! xyz"

Now, I would like to run the "Solver" package on A1, such that it gives a value of say 5.
How can I achive this feat? I use the following code for Solver:

SolverReset
SolverOk SetCell:="A1", MaxMinVal:=3, ValueOf:="5", ByChange:="B1"
Call SolverSolve
SolverFinish


Obviously, the problem is that "mybook.xls! xyz" is not run during the solver optimization stage,
and hence I do not get any result?

Any ideas on how to make this work? I tried the INDIRECT function, but this does not seem to run
my macro.

Many thanks for your help!
 
Replies continue below

Recommended for you

You can only do it if you write your macro to be a user-defined function (Function instead of Sub)

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
IRStuff,

Sorry for the late reply.

>Is this for school?

Quite insulting :)

No, I have a doctorate in engineering and I have done enough time at school :)

XLNew.
 
Status
Not open for further replies.
Back
Top