+ Reply to Thread
Results 1 to 4 of 4

How to make solver solve for selected cells

  1. #1
    Registered User
    Join Date
    12-19-2014
    Location
    Turkey
    MS-Off Ver
    2007
    Posts
    3

    Question How to make solver solve for selected cells

    Hello all,
    I need some help for combining two vba codes; selected cells and solver.

    First, I wanted to find cells in column C starting "C2" till last non-blank cell (even if blank cells has formula, if cells returns "", then assume it is blank), so here is the code:

    Please Login or Register  to view this content.
    Secondly, I wanted to write a solver code which has "cellref" and "bychange" cells should be the above selected cells but I couldn't find a way to combine these selected cells with solver code. Here is the solver code:

    Please Login or Register  to view this content.
    So can you please help me how can I replace "$C$2:$C$38" with selected cells code?
    Thanks in advance
    Last edited by Fotis1991; 12-19-2014 at 06:57 AM. Reason: Pls use code tags around your codes.

  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: How to make solver solve for selected cells

    I see you thread is marked "Solved" if it really is so prehaps you could upload the solution.

    If this was a mistake i.e. your problem is not solved you must unmark your thread in order to get help. Check under thread tools if you can remove the solved setting. If not you must ask a "Forum Guru" or higher to help you.

    Alf

  3. #3
    Registered User
    Join Date
    12-19-2014
    Location
    Turkey
    MS-Off Ver
    2007
    Posts
    3

    Re: How to make solver solve for selected cells

    Here is the solution:

    Sub SelectedCells()

    Range("C2").Resize(Columns("C").Find(What:="*", After:=Range("C1"), LookIn:=xlValues, SearchDirection:=xlPrevious).Row - 1).Select

    SolverReset
    Solveradd Cellref:=Selection.Address, Relation:=3, formulatext:="1"
    SolverOk SetCell:="N4", MaxMinVal:=3, Valueof:="0", ByChange:=Selection.Address
    SolverSolve userFinish:=True

    End Sub


  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: How to make solver solve for selected cells

    Thanks for adding the solution to your problem

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using Solver to solve across multiple cells
    By Texans57 in forum Excel General
    Replies: 5
    Last Post: 11-19-2012, 07:19 PM
  2. Replies: 0
    Last Post: 11-10-2008, 12:26 PM
  3. Solve without Solver
    By scantor in forum Excel General
    Replies: 1
    Last Post: 11-08-2008, 12:06 PM
  4. Can Solver solve this?
    By nirani in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2005, 09:05 AM
  5. How do you use solver to solve a polynomial
    By DW in forum Excel General
    Replies: 1
    Last Post: 06-07-2005, 08:05 AM

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