+ Reply to Thread
Results 1 to 12 of 12

Loop Solver Macros

  1. #1
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Loop Solver Macros

    Hi,

    I'm new to VBA or macros. I am trying to solve multiple cells in which the inputs also changes. Following is the recorded Macros.

    Please Login or Register  to view this content.
    I wanted the loop to change the values of D3 and G4 by assigning T3-T28 into D3 and U3-U28 into G4. Once the input is changed, I want to solve so that cell B2 minimum by setting B25>= B26 and B39<=B40. The variables that cells that are fixed are B2, B25, B26, B39, and B40 while the one that are changing are T3-T28 and U3-U28 which will be assigned into D3 and G4. I apologize if this isn't to clear.

    I appreciate your help.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Loop Solver Macros

    Would you mind supply us with a workbook with your data (it could be dummy data if sensitive ones)? It will help us create a macro to suit your layout.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop Solver Macros

    Hi,

    Yes, I can provide you with a trial worksheet. I hope this wold help. Following is the trial file. I appreciate your help.
    Last edited by dbie21; 11-19-2012 at 05:09 PM.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Loop Solver Macros

    nothing is attached to your post. Please retry.

  5. #5
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop Solver Macros

    Hi,

    I did attached something earlier however I just removed it since I didn't receive any response. I will attach it again now. Here's the program.
    Last edited by dbie21; 11-20-2012 at 10:59 AM.

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Loop Solver Macros

    Here is a macro that should work:
    Please Login or Register  to view this content.
    Hoping this help

  7. #7
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop Solver Macros

    Thank you for your help. I'm still not sure on how to run the macros. So after I opened up the VBA window and edited the module, do I just need to run it? I tried to run but excel keep notifying me "Compile Error: Sub or Function Undefined". Is this because I have not called in the worksheet into the VBA? Thank you.

  8. #8
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Loop Solver Macros

    No, it is because of the "SolverOk" function. You have to get into the VBA editor and click on " tools" in the top menu. Then select "Reference" then look for "Solver" in that window and make sure you tag the box on its left. Click OK and get back to the editor. You can run the macro from Excel by clicking on the "Developper" menu then on "Macro" then selecting the macro name you want and click the Run button.
    Hoping this is clear enough.

  9. #9
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop Solver Macros

    Thank very much for your help. This works. I appreciate your help.

  10. #10
    Registered User
    Join Date
    11-18-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Loop Solver Macros

    Is there anyway that the macro program can include to approve to solve ("OK") in the cycle. I realized that I have to click ok for each cell that needed to be solved.

  11. #11
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Loop Solver Macros

    Try changing this line:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.

  12. #12
    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,784

    Re: Loop Solver Macros

    Try changin line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Alf

+ 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