+ Reply to Thread
Results 1 to 16 of 16

Selecting lowest value in each column when inputting number of selections needed

  1. #1
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Selecting lowest value in each column when inputting number of selections needed

    Thank you to everyone that helped!
    Last edited by CooledLead; 08-08-2019 at 11:04 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Selecting lowest value in each column when inputting number of selections needed

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    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: Selecting lowest value in each column when inputting number of selections needed

    You could use solver with a binary grid.

    Bin_Grid.jpg

    solver result is not obvious as none of the lowest values are selected (range E4:G4) but the total cost for the sum of cars will be the lowest (see object f. C20).

    Alf
    Last edited by Alf; 08-01-2019 at 01:22 AM.

  4. #4
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    I have attached what should be highlighted given this scenario. I just need it to be automated now
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    I am not sure I understand. I have attached an excel file with the scenario that I've created, however, I now need it to be automated in highlighting the correct cells.

  6. #6
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    Thank you! I have uploaded a sample excel file if anyone would be willing to help.

  7. #7
    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: Selecting lowest value in each column when inputting number of selections needed

    Hi JeteMc

    Her is the file & setup you asked for.

    Alf
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    I really appreciate the help. However, this solution still requires manual input into the binary grid. I need it to analyze the cost grid and automatically tell what locations on the cost grid give the smallest cost.

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,562

    Re: Selecting lowest value in each column when inputting number of selections needed

    There may be less manual input than you are thinking.
    I took the liberty of adding a formula to L12:P12 that would get the number of cars needed at each location from the already entered B17:B21.
    The formula is: =INDEX($B17:$B21,MATCH(L4,$A17:$A21,0))
    So all that the user needs to do is to select cells L5:P9, type the number 1 and press the Ctrl and Enter keys then open the Solver > Select 'Solve' and 'OK' (as Alf has already it set up)
    I also added a very simple conditional formatting rule (=L5 light green fill and green font) to the grid B5:F9. I left the original cell highlighted so that you could compare.
    One benefit of Alf's method is that the choices it made save $0.24.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  10. #10
    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: Selecting lowest value in each column when inputting number of selections needed

    this solution still requires manual input into the binary grid.
    Not really, from JeteMc you got the index / match formula that sets up the demand for cars. Then you clears the range L5:P9 and you run solver. That's all there is to it.

    This setup is a general model that could be used if you do have a specific choice in order to find a max, a min or a specific value. This you decide by setting the objective to what you wish to achieve.


    Alf

  11. #11
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    Thank you so much for your response. I think Alf's method works now that I looked at it more, however, now the trouble is if I have for instance 5 cars to pick from but only need to send 4 away, the solver still populates the cells for 5 cars. I guess I need it to exclude the most expensive car. How do I change that? Again thank for your help.

  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,758

    Re: Selecting lowest value in each column when inputting number of selections needed

    now the trouble is if I have for instance 5 cars to pick from but only need to send 4 away
    This is where you change the demand line. Solver model is setup to this constraint:
    Please Login or Register  to view this content.
    i.e. the number of cars selected should be equal to or greater than the demand. Since the object function is set to minimum solve will pick the smallest number of cars that meets the demand because adding one extra will increase cost.

    So you could of course change this line to
    Please Login or Register  to view this content.
    i.e number of cars selected should be equal to the demand and you will get the same solution as before. But occasionally there can be advantages in setting a constraint "equal to and greater than" as this may produce a solution depending when equal to will not make it possible for solver to find a solution.

    exclude the most expensive car
    You specify the location the car should go to in your model and this determines the car cost and solver will give you the cheapest combination to meet the demands.

    Alf

  13. #13
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    Sorry it works like you had it. I entered one of the constraints in solver incorrectly. Thank you Alf and Jetco for your help!

  14. #14
    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: Selecting lowest value in each column when inputting number of selections needed

    You are welcome and thanks for feedback

    Alf

  15. #15
    Registered User
    Join Date
    07-31-2019
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Selecting lowest value in each column when inputting number of selections needed

    Actually I lied. No I have the problem of column A having a special calculation. I am using an IF statement like IF(Long Equation,0,Long Equation). Problem is that Solver does not recognize or use the returned zero. I don't know if I need to change the data type or put "" around it. Thank you again

  16. #16
    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: Selecting lowest value in each column when inputting number of selections needed

    I am using an IF statement like IF
    The solver simplex LP engine does not work with "IF" statement, try to change Solving method to "GRG Nonlinear" and see if this works instead.

    If not upload your file with the special calculation so forum members can have a go at finding a solution for you.

    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. [SOLVED] Selecting the highest or lowest number in a cell range
    By Oblisgr in forum Excel General
    Replies: 4
    Last Post: 05-26-2018, 06:24 AM
  2. Replies: 2
    Last Post: 02-26-2018, 12:31 PM
  3. Selecting Lowest Number from Data in a Single Cell Separated by Comma
    By hasanrazaque in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2016, 12:13 AM
  4. Replies: 5
    Last Post: 02-13-2014, 05:37 PM
  5. Replies: 5
    Last Post: 04-17-2012, 12:28 PM
  6. Replies: 12
    Last Post: 01-13-2011, 03:58 PM
  7. Selecting lowest number in a row of cells
    By thedaddy in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 03-08-2008, 02:27 PM

Tags for this Thread

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