• Solver Macro (2002)

    Author
    Topic
    #443431

    I ran Excel’s Solver and set a target cell, the constraints and the variable cells, and it all ran perfectly.

    However, I would now like users to be able to change the variable cells and for the Solver to recalculate automatically.
    I don’t want users to have to type and re-input all the constraints etc.

    Does anyone know of vba code to do this.

    Thanks

    Robert

    Viewing 0 reply threads
    Author
    Replies
    • #1069587

      Calculating a solution uses a lot of resources, so I don’t think it is a good idea to let the Solver recalculate automatically each time one of the input cells is changed. Instead, I’d do the following:
      – Set a reference to the SOLVER in Tools | References… in the Visual Basic Editor. If you’ve already set up the Solver, the references should be near the top of the list, so you only need to tick its check box and click OK.
      – Create the following simple macro:

      Sub SolveIt
      SolverSolve True
      End Sub

      – Create a command button from the Forms toolbar on the worksheet and assign the SolveIt macro to it.

      The user can click the command button after having changed one or more input cells.

      • #1069590

        I would never have thought to reference the Solver Add-in
        That works perfectly. Thanks as always, Hans.

        Regards

        Robert

    Viewing 0 reply threads
    Reply To: Solver Macro (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: