+ Reply to Thread
Results 1 to 3 of 3

Solver Loop

  1. #1
    Registered User
    Join Date
    01-08-2011
    Location
    austin
    MS-Off Ver
    Excel 2010
    Posts
    2

    Solver Loop

    HELP

    I am very new to Excel 2010, and fairly new to VBA.

    I am trying to create a VBA loop to run the excel 2010 solver. Even when i record a macro while manually running the solver, when i go into the VBA code and try to run it from the editor, it has a 'compile' error on the line that starts with SolverOK.

    If I want to set cells A3:A10 equal to cells B3:B10, while changing cells C3:C10, how can I write that code. I've tried several times but have not succeeded.

    Here's the recorded macro for just the first iteration:

    Sub Macro5()
    '
    ' Macro5 Macro
    '
    '
    SolverOk SetCell:="$A$3", MaxMinVal:=3, ValueOf:="$B$3", ByChange:="$C$3", _
    Engine:=1, EngineDesc:="GRG Nonlinear"

    SolverSolve
    End Sub

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

    Re: Solver Loop

    Welcome to the forum.

    You need to set a reference to Solver.

    In the VBE, Tools > References, browse to C:\Program Files\Microsoft Office\OFFICExx\Library\SOLVER, change the file type dropdown to *.xls, *.xla, and pick SOLVER.XLA

    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
    01-08-2011
    Location
    austin
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Solver Loop

    WOW. I've spent HOURS trying to get this to work. And you've solved it in seconds. I can't thank you enough.

    I will go back to forum rules and add CODE tags.

    Thank you so much

+ 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