+ Reply to Thread
Results 1 to 7 of 7

Find value in two columns and return based on order

  1. #1
    Forum Contributor
    Join Date
    07-05-2012
    Location
    Stockholm
    MS-Off Ver
    Excel 2010
    Posts
    162

    Find value in two columns and return based on order

    Hi,
    I'm trying to create a formula that checks column A for a value (e.g. "Alpha") and then checks column B ("Status") to return a value based on a certain order. In this example the order should be Red, Amber, Green and finally Completed.

    For example, if any of the values "Alpha" in column A has a corresponding "Red" value in column B, the overall status should be "Red". I no "Red" value exists, it should check for Amber, then Green and finally Completed.

    Any ideas?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,005

    Re: Find value in two columns and return based on order

    Try

    "Helper" in C

    =INDEX($I$2:$I$5,MATCH(B2,$J$2:$J$5,0))

    in E2

    =IF(COUNTIFS($A$2:$A$10,E$1,$C$2:$C$10,1),"Red",INDEX($J$2:$J$5,MAX(IF($A$2:$A$10=E$1,$I$2:$I$5))))

    ...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.

    Then copy across

    Headings are "Alpha", "Beta", "Gamma"
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-05-2012
    Location
    Stockholm
    MS-Off Ver
    Excel 2010
    Posts
    162

    Re: Find value in two columns and return based on order

    Thanks JohnTopley!

    When I test this and replace "Red" with "Amber" for the Alpha value it returns "Completed"? It should return Amber. Same thing if I change three of the values to "Green" and keep one as "Completed".

    Am I perhaps missing something or is the formula not reflecting that in you attached file?

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,904

    Re: Find value in two columns and return based on order

    What are your expected results in E2,F2 & G2 of attached file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,904

    Re: Find value in two columns and return based on order

    e2=IFERROR(INDEX($J$2:$J$5,MATCH(1,INDEX((COUNTIFS($A$2:$A$10,TRIM(SUBSTITUTE(E$1,"Status","")),$B$2:$B$10,$J$2:$J$5)>0)+0,0),0)),"")
    Try this and copy towards right

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,005

    Re: Find value in two columns and return based on order

    My error

    =INDEX($J$2:$J$5,MIN(IF($A$2:$A$10=E$1,$C$2:$C$10)))

    ...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.

  7. #7
    Forum Contributor
    Join Date
    07-05-2012
    Location
    Stockholm
    MS-Off Ver
    Excel 2010
    Posts
    162

    Re: Find value in two columns and return based on order

    Thanks JohnTopey and nflsales!

    Both works perfect!
    Many thanks! I will set this as resolved.

+ 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. Export columns based on alphabetical order
    By rpetty in forum Excel General
    Replies: 6
    Last Post: 07-26-2017, 10:48 PM
  2. [SOLVED] Need formula to return value from table based on varying order of column headers
    By ncpcpa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-13-2015, 02:44 PM
  3. Find data based off unique identifiers and return only columns showing data
    By yomamma34 in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-23-2014, 05:03 PM
  4. Replies: 11
    Last Post: 03-02-2014, 07:16 PM
  5. Replies: 0
    Last Post: 04-10-2012, 12:39 PM
  6. How to order columns based on maximum value in each column?
    By guilhermepc in forum Excel General
    Replies: 0
    Last Post: 01-16-2012, 08:14 PM
  7. how to re-arrange columns based on a specified order
    By 2seas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-05-2012, 10:06 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