×
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

Using Excel Solver and VBA User Defined Functions

Using Excel Solver and VBA User Defined Functions

Using Excel Solver and VBA User Defined Functions

(OP)
I would like to use Excel's Solver to minimize the sum of the square errors between observed data and a model.  I know how to do this if the model is an Excel function in cells in the worksheet.  However, I am working with a very complicated series of functions that I would like to be user-designed functions (UDF) written in VBA.  Is it possible to use Solver to optimize a cell in an Excel file that is a function of a VBA UDF?  I have attached a very simple model illustrating what I am trying to do, where "model" is a VBA UDF, and I would like to use Solver to minimize D9 by changing the parameters G4 and G5.

Thanks very much for any help you can provide.

RE: Using Excel Solver and VBA User Defined Functions

(OP)
Yes, I have tried it using the file attached to my first post, but Solver returns the original input values, not the optimized values.  If anyone knows how I can get solver to work with a VBA UDF, I would really appreciate the help.  Thanks!

RE: Using Excel Solver and VBA User Defined Functions

(OP)
Thanks for your help, IRstuff.  Could you please further explain "You need to pass the parameters to the function"?  I realize that with the simple example that I have included that there are many ways to find the solution.  However, this is just a very simplified example of what I am trying to do.  The real function that I want to use is not linear.

RE: Using Excel Solver and VBA User Defined Functions

Glad you've got it working.
However I think that your approach would be more "robust" if you set the Solver to minimise your target cell rather than trying to force it to zero.

RE: Using Excel Solver and VBA User Defined Functions

That'll get rid of the error message, but Solver will still have the closest solution, even with the error message.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

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! Already a Member? Login


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close