+ Reply to Thread
Results 1 to 7 of 7

Help in finding smallest value for given criteria

  1. #1
    Registered User
    Join Date
    04-25-2017
    Location
    Mumbai,India
    MS-Off Ver
    2013
    Posts
    3

    Help in finding smallest value for given criteria

    Hello Friends,

    I need a help in developing logic and small code for below small data. I have courier company names and their rates to deliver goods of type A, B, C to given pin code. I want to develope a small code in which I will give object type (A, B,C) and Pin code. It will return me 'Courier company name' with lowest fare.

    Input --> Pin code & A/B/C
    Output --> Courier

    Any kind of help is greatly appreciated.

    Courier Pin Code A B C
    BLUEDART 110001 219 447 561
    BLUEDART 110002 219 447 561
    BLUEDART 110003 219 447 561
    BLUEDART 110004 219 447 561
    DELHIVERY 110001 410 410 410
    DELHIVERY 110002 410 410 410
    DELHIVERY 110003 137 137 137
    SAW- DTDC 110001 258 270 281
    SAW- DTDC 110002 258 270 281
    SAW- DTDC 110003 258 270 281

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Help in finding smallest value for given criteria

    Assuming data in A1:E11 range including header.

    Pin Code in I2, Object Type (A/B/C) in J2

    Formula would be...
    =INDEX($A$2:$A$11,MATCH(I2&MIN(INDEX($C$2:$E$11,IF(B2:B11=I2,ROW(2:11)+1),MATCH(J2,C1:E1,0))),B2:B11&INDEX(C2:E11,,MATCH(J2,C1:E1,0)),0))

    Confirmed as array. See attached sample.

    Note: Depending on data set, you may want to add separator (such as "-") between concatenations.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-25-2017
    Location
    Mumbai,India
    MS-Off Ver
    2013
    Posts
    3

    Re: Help in finding smallest value for given criteria

    Thanks a lot CK76. You are genious
    I didn't think about match index before. In the excel you attached, it is giving #N/A for Pin code - 110002 for all objects. What can be the reason?

  4. #4
    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
    53,048

    Re: Help in finding smallest value for given criteria

    Did you enter that using CTRL SHIFT ENTER and not just enter? It is an array formula
    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

  5. #5
    Registered User
    Join Date
    04-25-2017
    Location
    Mumbai,India
    MS-Off Ver
    2013
    Posts
    3

    Re: Help in finding smallest value for given criteria

    Quote Originally Posted by FDibbins View Post
    Did you enter that using CTRL SHIFT ENTER and not just enter? It is an array formula
    Yes, I did try with CTRL SHIFT ENTER. Same #N/A error.

  6. #6
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2503 Build 16.0.18604.20000) 64-bit
    Posts
    3,992

    Re: Help in finding smallest value for given criteria

    Quote Originally Posted by harshadborde View Post
    Yes, I did try with CTRL SHIFT ENTER. Same #N/A error.
    Try

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Help in finding smallest value for given criteria

    Woops, my bad. I didn't fully test the formula. Go with Ankur's formula.

+ 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. Finding next smallest value?
    By wilson33 in forum Excel General
    Replies: 6
    Last Post: 03-13-2016, 11:11 AM
  2. Finding the column with the smallest value..
    By gbzilla in forum Excel General
    Replies: 10
    Last Post: 07-09-2012, 08:22 AM
  3. Finding smallest number
    By Benjaminjoseph in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2006, 10:14 AM
  4. Finding Smallest Value
    By Phil in forum Excel General
    Replies: 5
    Last Post: 05-28-2006, 08:30 PM
  5. [SOLVED] Finding the three smallest numbers
    By Jan Kronsell in forum Excel General
    Replies: 2
    Last Post: 05-13-2006, 01:35 PM
  6. [SOLVED] finding next smallest value in a column
    By Greg in forum Excel General
    Replies: 2
    Last Post: 02-02-2006, 02:10 PM
  7. Finding smallest numbers
    By Mike7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2005, 07:39 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