Forum Discussion

Dan1ExcelUser's avatar
Dan1ExcelUser
Copper Contributor
Jan 15, 2025
Solved

Compare two workbook and return the cell value

Hi,

I've two sheets with the following structure:

  • Sheet1 (Main) has columns A (Last Name), B (First Name), and C (Email);
  • Sheet2 has columns A (Last Name), B (First Name), and C (Email).

I used the formula =IFERROR(IF(MATCH(A1, lookup_array, 0), "Yes"), "No") to find mismatching values between these two sheets.

Now, I'd like to improve it to return me the cell values in the column C (Email) from Sheet2 to Sheet1 in column D (Good Email) if there is a match on columns A or B.

  • HansVogelaar's avatar
    HansVogelaar
    Jan 15, 2025

    In D2 on Sheet1:

     

    =XLOOKUP(A2&" "&B2, 'Sheet2'!$A$2:$A$1000&" "&'Sheet2'!$B$2:$B$1000, 'Sheet2'!$C$2:$C$1000, "")

    Replace Sheet2 to the real name of that sheet, then fill down.

3 Replies

    • Dan1ExcelUser's avatar
      Dan1ExcelUser
      Copper Contributor

      I want to do both if possible. Because there are some cases where A and B are matching.

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        In D2 on Sheet1:

         

        =XLOOKUP(A2&" "&B2, 'Sheet2'!$A$2:$A$1000&" "&'Sheet2'!$B$2:$B$1000, 'Sheet2'!$C$2:$C$1000, "")

        Replace Sheet2 to the real name of that sheet, then fill down.