I have a following table structure:
--- c1 ------- c2 ---- c3 ------ c4
r1: **0001** **word1**
r2: 0002 word2 **0001** **word1**
r3: 0003 word3 0002 word2
I would like to set column three values automatically, so that if there is some word in column 4, then program should check column 2 and try to find the same word. If found, then column 1 value should be used as a column 3 value.
I could do that manually, but it's more work and it gets problematic if I ever add new rows. Column 1 value is equal to row number, so it's updated automatically if new rows added. Now I would like to set my data so that also column 3 would be updated automatically in those cases.
What is the right formula to make that happen?
If you slightly rearrange your worksheet, then the VLOOKUP()
function can be used. I swapped your A
and B
(first and second) columns to arrive at this:
--- A ---- B ---- C --- D
r1: word1 0001
r2: word2 0002 0001 word1
r3: word3 0003 0002 word2
Enter into C1
:
=VLOOKUP(D1, A$1:B$3, 2, FALSE)
and copy this formula down the C
column.
The reason for swapping the first two columns is that VLOOKUP()
always looks in the first column for the match.
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.