×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Solver-Macro loop

Solver-Macro loop

Solver-Macro loop

(OP)
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!

RE: Solver-Macro loop

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: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: Solver-Macro loop

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources