Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solver-Macro loop

Status
Not open for further replies.

XLnew

Computer
Joined
Dec 21, 2008
Messages
12
Location
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!
 
Is this for school?

TTFN

FAQ731-376
 
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.

Part and Inventory Search

Sponsor

Back
Top