+ Reply to Thread
Results 1 to 9 of 9

Functions inside Solver algo

  1. #1
    Registered User
    Join Date
    07-25-2009
    Location
    New York City, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Functions inside Solver algo

    Hey guys, I have an array of quantities in my VBA code that i want to change to maximiaze a value. I am having trouble incorporating the VBA function into the solver methodology. I am currently copying these the quantities back and forth from the function to the worksheet and then clicking a button that solves the worksheet values by calling the function..... only it doesn't work yet!

    Part of below is pseudo code:



    Please Login or Register  to view this content.

    Inside RunVBAFunction it sets the worksheet values to the array that is used in RunVBAFunction. It also then prints out a formula and value to the "A1" cell that is being maximized. The function runs correctly and spits out a value correctly to the workshet... but it is only called once though, and no itterative process occurs. I also tried putting this solver process in a loop but there was not maximination going on.

    Please help, thanks in advance!!!
    Last edited by Zward25; 07-26-2009 at 03:21 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Functions inside Solver algo

    Welcome to the forum.

    Please take a few minutes to read the forum rules and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-25-2009
    Location
    New York City, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Solver question in VBA

    Hey guys, I have an array of quantities in my VBA code that i want to change to maximiaze a value. I am having trouble incorporating the VBA function into the solver methodology. I am currently copying these the quantities back and forth from the function to the worksheet and then clicking a button that solves the worksheet values by calling the function..... only it doesn't work yet!

    Part of below is pseudo code:


    Please Login or Register  to view this content.
    ' Inside RunVBAFunction it sets the worksheet values to the array that is used in RunVBAFunction. It also then prints out a formula and value to the "A1" cell that is being maximized. The function runs correctly and spits out a value correctly to the workshet... but it is only called once though, and no itterative process occurs. I also tried putting this solver process in a loop but there was not maximination going on.

    Please help, thanks in advance!!!
    Last edited by Zward25; 07-26-2009 at 03:22 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Solver question in VBA

    Threads merged.

    Second request, Zward -- please read the forum rules, and then edit your post to add code tags.
    Last edited by shg; 07-26-2009 at 12:41 PM.

  5. #5
    Registered User
    Join Date
    07-25-2009
    Location
    New York City, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Solver question in VBA

    Hey I'm reading the rules... I've highlighted my code. I don't see this # that tags the code.

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Functions inside Solver algo

    go advanced, the option is there
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Registered User
    Join Date
    07-25-2009
    Location
    New York City, USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Functions inside Solver algo

    I am not sure what you mean by 'go advanced'. There is an option to add a function/procedure into one's SolverSolve? ?

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Functions inside Solver algo

    Click the Edit button on your post.

    Click the Go Advance button.

    Select the code in your post.

    Push the button with the octothorpe (#).

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Functions inside Solver algo

    Thank you.
    but it is only called once
    Yes indeed, you are only calling it once each time DoSolver runs.

    If you want to call it more than once, you need to put a loop around it in your code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1