Results 1 to 8 of 8

Solver in a Loop for multiple rows by changing multiple columns

Threaded View

  1. #1
    Registered User
    Join Date
    04-25-2018
    Location
    Ceará, Brazil
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Solver in a Loop for multiple rows by changing multiple columns

    Hello guys.

    I was having trouble running the Solver in multiple rows. However, I saw in this forum several threats that helped me evolve a lot using VBA (I'm starting my studies now in this language and solved the problem with Solver in a Loop).

    I know it must be something simple that I'm missing, however, I cannot do that for two columns at a time (in this case, the P and the R columns).
    Here are the spreadsheet and the code.
    I would also like to add the R column.

    Best Regards,
    Gláuber.

    Set Objective: $AI$12
    To: Min
    By Changing: $P$12;$R$12
    
    
    Option Explicit
    
    Sub LoopSolv()
    
    Dim i As Integer
    
    For i = 12 To Range("P" & Rows.count).End(xlUp).Row
    
    If Cells(i, "P") <> "" Then
    SolverReset
    SolverOk SetCell:=Cells(i, "AI").Address, MaxMinVal:=2, ValueOf:=0, ByChange:=Cells(i, "P").Address, Engine:=1 _
    , EngineDesc:="GRG Nonlinear"
     SolverAdd CellRef:=Cells(i, "AI").Address, Relation:=2, FormulaText:=Cells(i, "AI").Address
    SolverSolve Userfinish:=True
    End If
    
    Next
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Solver - Multiple By Changing Variables
    By PingPongYeah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2018, 02:20 PM
  2. Search Multiple Columns and Rows - Show results in Multiple columns and rows
    By heykeighley in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-12-2015, 10:16 AM
  3. Filter - Multiple Columns - Loop through Visible Rows issue
    By Vinod Krishna.C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2014, 05:30 PM
  4. [SOLVED] Using "SOLVER" to match two columns, but how to copy it for multiple rows ??? (URGENT)
    By hshahad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2013, 11:31 AM
  5. Replies: 3
    Last Post: 03-27-2013, 03:58 PM
  6. Run Solver Multiple Times (while changing constraints and goal for each iteration)
    By pmw1218 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2013, 04:17 PM
  7. Changing Multiple Columns into Multiple Rows
    By Tester36 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2011, 02:11 PM

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