I have 2 sheets
In the first sheet I have
Names and Countries
and in the another sheet I have Countries and Countries_id
I want to add all "Countries_id" into the first sheet into the appropriate cell
Example
Sheet_one : Names and Countries
Name Country
Tomy En
Aleks Fr
Jack En
Monica Fr
Sheet_two : Countries with id
Country id
En 1
Fr 2
Result :
Name Country Country_id
Tomy En 1
Aleks Fr 2
Jack En 1
Monica Fr 2
You should be able to do this with a simple VLOOKUP.
If we say that sheet 1 starts in cell A1, then add the following formula in C2:
=VLOOKUP(B2,Sheet2!$A$2:$B$3,2,FALSE)
This says "look up the value found in B2 in the first column of the range on sheet 2 that goes from A2 to B3. When you find an exact match ("false"), return the corresponding value from column 2.
Copy this to all cells under Country_id
and you're done.
Note - you need the $
signs for the $A$2:$B$3
since that reference is ABSOLUTE - as you copy down, you want to refer to the same range (could be done by naming the range if you wanted). The B2
value is RELATIVE, so that when you copy down, you get C2, D2, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.