Link to home
Start Free TrialLog in
Avatar of Robert Schumann
Robert SchumannFlag for United States of America

asked on

Compare Two Columns to another Two Columns and Return "X" to another Column

Hi

I need to compare column H & I to D & E and if there is a match to place an "X" in column G.
Sounds simple enough but can't seem to get it.

Thanks in advance,
Bob CompareColumns.xls
Avatar of Carlos Ramirez
Carlos Ramirez
Flag of United States of America image

Your sample doesn't have any pair that matches but this should work:

=IF(UPPER(H9)&UPPER(I9)=UPPER(D9)&UPPER(E9),"X","")

(tested with row 9)
D9=Aikenhead
E9=Jim
not clear ...
Two clarifications needed:
Do you mean if the combination in D&E exists in H&i you want to place an X in column G?
Do the values in H&I need to be in upper case?
The suggested formula in cell G2 (copied down) would be:
=IF((H3&I3)=(D3&E3),"X","")

This will work, regardless of casing (upper, lower, proper), but not if there are spaces before or after.  Also, it would not match if the name has a middle initial (ex. "GARY W.")

There are no matches in the example workbook.

If, however, you are looking for ANY possible match (say, across two different rows), it will be considerably more difficult.  Also, your data set has variations on names (ex. "Jim" vs "James" Aikenhead).
Correction in my previous post, the formula in cell G2 should be:
=IF((H2&I2)=(D2&E2),"X","")

also, if you wanted to follow slycoder's logic to convert to upper case and test:
=IF(UPPER(H2&I2)=UPPER(D2&E2),"X","")
After thinking about it more -

Added a column J and used If condition with Match in column G

Please see attached

CompareColumns-Update.xls
Avatar of Robert Schumann

ASKER

Yes, the combination in D&E exists in H&I and then place an X in column G.  I'm basicly determining Last Name and First name exist in both sets of columns.  And if they do then place an X in column G.
The values in H&I by default are uppercase, does this matter?
And I should have added that is solution needs to be a macro.
The names Israel Agosto and Will Altig and the only matches
Are you looking for matches? - For example H8 and I8 are the same as D6 and E6 except for case. This is different than comparing columns as that would indicate a one to one relationship in most cases such as C6 = D6.
The comparison slycoder provided would be a one to one comparison and would convert the data to upper case before comparing. This would not work out as true in your sample data since E9 = "Judith" and I9 = "JIM"
Slycoder

How would this be put into a Macro, that would also move H & I down one row first and then delete column J after the macro finished.
ASKER CERTIFIED SOLUTION
Avatar of Carlos Ramirez
Carlos Ramirez
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Solution attached with this post.

Things to note:
1. Added column J as a working column (You may choose to keep it hidden)
2. Values in H and I should match values in column D and E (Either all upper case or all lower case or all camel case) Only then will they match - formula used is case sensitive.

(Make note of the formulas in col G and J (Thats all you need)
 CompareColumns.xls
Great work, thank you very much!!