+ Reply to Thread
Results 1 to 5 of 5

Comparing two columns and if there is a match then return values from a different column

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    3

    Comparing two columns and if there is a match then return values from a different column

    Hi,

    I have 3 columns.
    Need to check whether col1 value exist in col2 and if it does, then pick up the values from col3 adjacent to col2 and populate the values in col 4 & col 5. For a value in col1, there can be multiple values in col 3(at max 2).

    Capture.PNG

    I have attached an image containing my input and output.


    Please help.
    Last edited by skywalkertinks; 05-25-2017 at 06:38 PM.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Comparing two columns and if there is a match then return values from a different colu

    Hi skywalkertinks- Paste this ARRAY FORMULA in D1 and then press CTRL+SHIFT+ENTER to confirm array status.
    Then use the drag-handle (little green box, lower right corner) to fill across, and down.

    = IFERROR(INDEX($C$1:$C$11,MATCH(0,COUNTIF($C1:C1,$C$1:$C$11)+($B$1:$B$11<>$A1),0)),"")
    Untitled.png

    NOTE: If the formula appears as TEXT after pasting, there's an unwanted leading space in front of the "=". Delete it, then press CTRL+SHIFT+ENTER again.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 05-25-2017 at 07:56 PM.

  3. #3
    Registered User
    Join Date
    05-25-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    3

    Re: Comparing two columns and if there is a match then return values from a different colu

    Thanks a lot for your help Leelnich. It worked.

    If you could please explain the formula it would be great!

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Comparing two columns and if there is a match then return values from a different colu

    Happy to help!
    Untitled.png

    This part achieves uniqueness:
    COUNTIF($C1:C1,$C$1:$C$11)

    Note that the first C1 is absolute, while the second is relative, so when copied to right, it would read $C1:D1.
    So this clause yields an array with a 1 for each element in column C that was already found, and a 0 for the rest.

    In truth, I should have placed the formula starting in column E to avoid overlap with the data in Column C.
    This would avoid some possible conflicts. The formula (in E1) would then read:

    = IFERROR(INDEX($C$1:$C$11,MATCH(0,COUNTIF($D1:D1,$C$1:$C$11)+($B$1:$B$11<>$A1),0)),"")
    Last edited by leelnich; 05-26-2017 at 05:41 AM.

  5. #5
    Registered User
    Join Date
    05-25-2017
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    3

    Re: Comparing two columns and if there is a match then return values from a different colu

    Thanks again

+ 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. INDEX/MATCH Formula issue-comparing dates in 4 columns to return a value
    By hopegriffin in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-06-2016, 05:15 PM
  2. [SOLVED] Help comparing two columns of data with same names different values (index match??)
    By exceldion in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-16-2015, 09:43 AM
  3. Replies: 1
    Last Post: 08-18-2014, 11:10 PM
  4. [SOLVED] Comparing values in two columns and highlighting cells that don't match
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-10-2014, 07:51 AM
  5. Comparing two text columns and return data based on an exact match
    By AShah33 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-04-2013, 04:23 PM
  6. Replies: 1
    Last Post: 01-23-2013, 08:59 PM
  7. Comparing 2 columns- if a match is found return a value in 3rd column
    By lineson in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 12-20-2011, 04:48 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