using lookup or similar

Danusia Waite 20 Reputation points
2025-10-07T02:51:08.1433333+00:00

I have 2 separated spreadsheets in a workbook. The first spreadsheet contains Column C with Codes listed and Column E wants to pick up a dollar value that is contained in the second spreadsheet corresponding to the same Account Code. The second spreadsheet Column A has the same Code as in the first spreadsheet and has a value either in Column D or in Column E. Which Formula Function should I use and what is the formula. I have tried XLOOKUP, VLOOKUP, MATCH and having errors such as N/A. "SPILL! and other. Please can someone help out

Microsoft Edge | Microsoft Edge development
0 comments No comments

Answer accepted by question author
Jack Dang (WICLOUD CORPORATION) 18,975 Reputation points Microsoft External Staff Moderator
2025-10-07T03:58:38.4833333+00:00

Hi @Danusia Waite ,

I understand how frustrating it can be to deal with #N/A or #SPILL! errors when trying to pull values from another sheet. Let’s break it down and get it working.

Issue Summary:

  • You have two sheets in the same workbook.
    • Sheet1:
      • Column C: account codes
      • Column E: needs the corresponding dollar value
    • Sheet2:
      • Column A: account codes
      • Column D or E: dollar value (it could be in either column)
  • You’ve tried XLOOKUP, VLOOKUP, MATCH, etc., but keep getting errors.

Step-by-Step Guidance:

  1. Check that account codes match exactly
    • Extra spaces or formatting differences can cause #N/A.
    • You can use =TRIM(C2) in a helper column to remove extra spaces.
  2. Decide which column to return from Sheet2
    • If the value is always in Column D, the formula is straightforward.
    • If the value could be in Column D or E, we need a formula that checks both.
  3. Using XLOOKUP (recommended for modern Excel)
    • If the value is always in Column D:
           =XLOOKUP(C2, Sheet2!A:A, Sheet2!D:D, "Not Found")
      
      This looks for the code in Sheet2 Column A and returns the value from Column D.
    • If the value might be in Column D or E:
           =XLOOKUP(C2, Sheet2!A:A, Sheet2!D:D, XLOOKUP(C2, Sheet2!A:A, Sheet2!E:E, "Not Found"))
      
      This first tries Column D, and if no value is found, checks Column E.
  4. Using VLOOKUP (older Excel versions)
    • If the value is in Column D:
           =VLOOKUP(C2, Sheet2!A:D, 4, FALSE)
      
      VLOOKUP cannot easily check two columns, so you would need a helper column if the value could be in either D or E.
  5. Common causes of errors
    • #N/A: lookup value not found (extra spaces or mismatched formatting)
    • #SPILL!: the formula tries to return multiple results but cannot fit in the target cell

I suggest using XLOOKUP if your Excel version supports it. It handles missing values gracefully and is easier to manage than VLOOKUP. Also, make sure the account codes in both sheets are consistent in formatting and free from extra spaces.

If this helps fix the issue and my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.