+ Reply to Thread
Results 1 to 5 of 5

Thread: Compare columns

  1. #1
    Registered User
    Join Date
    05-06-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Compare columns

    I have a spreadsheet with 2 sheets. Sheet 1 column A has a list of servers. Sheet 2 has 5 columns (A-E). I want to compare what is in Sheet 1 Column A to the Columns on sheet 2. If there is a match of Column A Sheet 1 and Column A sheet 2, then return POK1. If there is a match between Column A Sheet 1 with Column B sheet 2, then return POK2. If there is a match between Column A Sheet 1 with Column C sheet 2, then return POK3. If there is a match between Column A Sheet 1 with Column D sheet 2, then return POK4. If there is a match between Column A Sheet 1 with Column E sheet 2, then return POK5.

    Any help is very much appreciated.

  2. #2
    Forum Guru Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    2,782

    Re: Help needed to compare columns and return specific output

    How about

    ="POK"&IF(COUNTIF(Sheet2!A:A,A2),1,IF(COUNTIF(Sheet2!B:B,A2),2,IF(COUNTIF(Sheet2!C:C,A2),3,IF(COUNTI F(Sheet2!D:D,A2),4,IF(COUNTIF(Sheet2!E:E,A2),5," not found")))))

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Help needed to compare columns and return specific output

    For the first value in sheet1, cell A2, put this formula in B2:

    =IF(ISNUMBER(MATCH($A2,Sheet2!A:A,0)), "POK1", IF(ISNUMBER(MATCH($A2,Sheet2!B:B,0)), "POK2", IF(ISNUMBER(MATCH($A2,Sheet2!C:C,0)), "POK3", IF(ISNUMBER(MATCH($A2,Sheet2!D:D,0)), "POK4", IF(ISNUMBER(MATCH($A2,Sheet2!E:E,0)), "POK5", "No Match")))))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    05-06-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Help needed to compare columns and return specific output

    Quote Originally Posted by JBeaucaire View Post
    For the first value in sheet1, cell A2, put this formula in B2:

    =IF(ISNUMBER(MATCH($A2,Sheet2!A:A,0)), "POK1", IF(ISNUMBER(MATCH($A2,Sheet2!B:B,0)), "POK2", IF(ISNUMBER(MATCH($A2,Sheet2!C:C,0)), "POK3", IF(ISNUMBER(MATCH($A2,Sheet2!D:D,0)), "POK4", IF(ISNUMBER(MATCH($A2,Sheet2!E:E,0)), "POK5", "No Match")))))

    Thanks. Seems to work well.

  5. #5
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,226

    Re: Compare columns

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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