+ Reply to Thread
Results 1 to 7 of 7

can I use IF function to compare 2 columns

  1. #1
    Registered User
    Join Date
    07-10-2006
    Posts
    4

    can I use IF function to compare 2 columns

    Hi

    I currently have 2 reports ... Both have peoples names in it. I would like to compare the names in one report to the names in the other report. If the names are the same I want the report to state ok, if not it needs to state WRONG

    Workbook 1

    Column A Last Name
    Colum B First Name
    Column C Location
    Column D - OK? WRONG? Is the last name in WB1 = the last name in WB2

    Worksbook 2

    Column A Last Name
    Colum B First Name
    Column C Location

    PLEASE HELP ME .......

  2. #2
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    the easiest way is just to use the inbuilt test. To illustrate

    In A1 enter Matt
    In B1 enter Mat
    in C1 enter =A1=B1
    C1 will read false. If you change B1 to Matt, C1 will change to true

  3. #3
    Toppers
    Guest

    RE: can I use IF function to compare 2 columns

    A simple IF comparison is only meaningful if you expect both lists to be
    identical in length, order and content: this effectively traps "typing"
    errors. If the lists are different lengths, then you will have to use another
    approach and probably compare the combined last name/first name of both
    workbooks to allow duplicate surnames.

    One way is to create a "helper" column in each workbook (e.g column E)
    containing the concatenation of last name & firstname, and then use (for
    example) in WB1 in Col F:

    =IF(COUNTIF([WB2.xls]Sheet1!$E:$E,E1),"OK","Wrong")

    HTH

    "Karen271077" wrote:

    >
    > Hi
    >
    > I currently have 2 reports ... Both have peoples names in it. I would
    > like to compare the names in one report to the names in the other
    > report. If the names are the same I want the report to state ok, if
    > not it needs to state WRONG
    >
    > Workbook 1
    >
    > Column A Last Name
    > Colum B First Name
    > Column C Location
    > Column D - OK? WRONG? Is the last name in WB1 = the last name in WB2
    >
    > Worksbook 2
    >
    > Column A Last Name
    > Colum B First Name
    > Column C Location
    >
    > PLEASE HELP ME .......
    >
    >
    > --
    > Karen271077
    > ------------------------------------------------------------------------
    > Karen271077's Profile: http://www.excelforum.com/member.php...o&userid=36195
    > View this thread: http://www.excelforum.com/showthread...hreadid=560961
    >
    >


  4. #4
    Registered User
    Join Date
    07-10-2006
    Posts
    4
    Hi Toppers,

    You are indeed correct, both lists are different in size. Again each employee has 2 records, for the purpose of data inteegrety I need both records to reflect exactly the same name. Lets just work with one column which is their last name. List 1 might say Cordova as a last name and list 2 might say cordova salinas. Whenever i have an issue like this my report needs to state false. I tried your formula but can't seem to work it out (is the condition case sensitive by any chance?

  5. #5
    Toppers
    Guest

    Re: can I use IF function to compare 2 columns

    It is not case sensitive and will return FALSE if comparing "Cordova" vs
    "Cordova Salinas" irrespective of case of either cell.

    So I don't understand why it is not working for you.

    "Karen271077" wrote:

    >
    > Hi Toppers,
    >
    > You are indeed correct, both lists are different in size. Again each
    > employee has 2 records, for the purpose of data inteegrety I need both
    > records to reflect exactly the same name. Lets just work with one
    > column which is their last name. List 1 might say Cordova as a last
    > name and list 2 might say cordova salinas. Whenever i have an issue
    > like this my report needs to state false. I tried your formula but
    > can't seem to work it out (is the condition case sensitive by any
    > chance?
    >
    >
    > --
    > Karen271077
    > ------------------------------------------------------------------------
    > Karen271077's Profile: http://www.excelforum.com/member.php...o&userid=36195
    > View this thread: http://www.excelforum.com/showthread...hreadid=560961
    >
    >


  6. #6
    Registered User
    Join Date
    07-10-2006
    Posts
    4
    Hi toppers ... now it's working
    Now I want to take it one step further ...

    So now I have compared

    WS 1 Column A - Cordova
    WS 2 Column A - Cordova Salinas - Result is displayed as WS1 Column B Wrong

    Now I would like to display the name cordova Salinas in WS1 Column C so that my people know the diffrenece

  7. #7
    Toppers
    Guest

    Re: can I use IF function to compare 2 columns

    =IF(B1="Wrong",VLOOKUP("*"&A1&"*",ws2!A:A,1,0),"")

    Or combine them in B1

    =IF(COUNT(ws2!A:A,A1),"",VLOOKUP("*"&A1&"*",ws2!A:A,1,0))

    This assumes that "Part" of the name exist i.e if "Cordova" is not in any
    part of the list, it will error so use:

    in C1

    =IF(B1="Wrong",IF(ISNA(VLOOKUP("*"&A1&"*",ws2!A:A,1,0)),"No
    match",VLOOKUP("*"&A1&"*",ws2!A:A,1,0)))

    OR

    in B1

    =IF(COUNT(Sheet2!A:A,!A1),"",IF(ISNA(VLOOKUP("*"&A1&"*",ws2!A:A,1,0)),"No
    match",VLOOKUP("*"&A1&"*",ws2!A:A,1,0)))

    HTH

    "Karen271077" wrote:

    >
    > Hi toppers ... now it's working
    > Now I want to take it one step further ...
    >
    > So now I have compared
    >
    > WS 1 Column A - Cordova
    > WS 2 Column A - Cordova Salinas - Result is displayed as WS1 Column B
    > Wrong
    >
    > Now I would like to display the name cordova Salinas in WS1 Column C so
    > that my people know the diffrenece
    >
    >
    > --
    > Karen271077
    > ------------------------------------------------------------------------
    > Karen271077's Profile: http://www.excelforum.com/member.php...o&userid=36195
    > View this thread: http://www.excelforum.com/showthread...hreadid=560961
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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