0
votes

I have 2 Excel spreadsheets and both sheets have a "Code" field and value that may or may not exist in both. In sheet1 and sheet2 there is also an "ID", i'm hoping that if the "ID" is populated in sheet1 and if the matching code exists in sheet2, a query can transfer the "ID" to sheet 2

SHEET1

enter image description here|

SHEET2

enter image description here

I can find the matching values using vlookup but my issue is getting the ID field to populate =VLOOKUP(A1,Sheet1!A:A,1,FALSE)

2
Have you tried a VLOOKUP yet? Have you researched any of the existing tutorials on VLOOKUP?BigBen
Yes i have, i can get the lookup to find matching but not add in the value from the ID fieldSenna
Please edit your question with the VLOOKUP formula you're using.BigBen
=VLOOKUP(A1,Sheet1!A:B,2,FALSE). You may want to (re)read a VLOOKUP tutorial.BigBen
Please (re)read a VLOOKUP tutorial.BigBen

2 Answers

1
votes

Instead: =VLOOKUP(A1,Sheet1!A:B,2,FALSE).

From Microsoft's help on Vlookup:

How to get started There are four pieces of information that you will need in order to build the VLOOKUP syntax:

  1. The value you want to look up, also called the lookup value.

  2. The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.

  3. The column number in the range that contains the return value. For example, if you specify B2:D11 as the range, you should count B as the first column, C as the second, and so on.

  4. Optionally, you can specify TRUE if you want an approximate match or FALSE if you want an exact match of the return value. If you don't specify anything, the default value will always be TRUE or approximate match.


Pay special attention to parameters 2 and 3.

Note that number 2 "The range where the lookup value is located" should be the full range where the first column of the range has the values to lookup and the last column of the range should contain the values you want to return. So your A:A only having one column, will only lookup and return values in column A. You want values returned from column B so it must be included as well, to become A:B.

Since column B is the second column in the lookup range of A:B then your third parameter will be 2 which leads to the vlookup at the top of this answer.

0
votes

This is what you are doing:

VLOOKUP(A1,Sheet1!A:A,1,FALSE)

(I will only talk about Sheet1!A:A and 1)

You are looking into column A and from there you are taking column number 1 (which is column A).

What you should be doing, this this:

VLOOKUP(A1,Sheet1!A:B,2,FALSE)

Look into table, made up of columns A and (up to) B, you will automatically look into the first column, and you return the value you find in column number 2 (which is column B).