+ Reply to Thread
Results 1 to 5 of 5

Solver with Macro - need guidance for a small project

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    57

    Solver with Macro - need guidance for a small project

    I tried to do small project on solver.

    Now I have faced a situation where I need your guidance to go forward.

    I attached herewith a Excelsheet with a solver modle & I wish to run it with a macro. I tried sevaral ways but stil I didn't find a solution. I need to load objecctive, variable cells & constraints to a solver modle & slove it just clicking the "solve button".



    pls help me to code this in VB or to write a macro.



    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver with Macro - need guidance for a small project

    You should start with an "empty" solver model.

    Click on "record macro" and then open up solver. Start filling all the solver values i.e. target cell, cells to change and constraints. When all this is done click solve.

    When solver finds a solution click ok and then click "stop recording". Congratulations you now have a macro to run solver! Close solver and right click on your solver button and select "Assign macro"

    Before you can use this macro you must set a reference to solver in visual basic.

    Before you can use the Solver VBA functions in the Visual Basic Editor, you must establish a reference to the Solver add-in. In the Visual Basic Editor, with a module active, click References on the Tools menu, and then select Solver under Available References. If Solver does not appear under Available References, click Browse, and then open Solver.xlam in the \Program Files\Microsoft Office\Office14\Library\SOLVER subfolder.
    Depending on the "starting point" for solver you may need to change the "´Max time" and number of "Iterations" for solver (click "Options" in the solver "window")

    Alf

  3. #3
    Registered User
    Join Date
    08-28-2012
    Location
    Sri Lanka
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Solver with Macro - need guidance for a small project

    Hi alf

    Great, it's working.
    thank you for your quick attention on my problem.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Solver with Macro - need guidance for a small project

    Good! If this fixes your problem could you please mark your thread "Solved"

    Alf

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Solver with Macro - need guidance for a small project

    @ prashantha

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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