[英]Set cell value based on value in other cell
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. 我想自动设置第3列的值,因此,如果第4列中有某个单词,则程序应检查第2列并尝试查找相同的单词。 If found, then column 1 value should be used as a column 3 value.
如果找到,则应将第1列的值用作第3列的值。
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.
第1列的值等于行号,因此,如果添加了新行,则会自动更新。 Now I would like to set my data so that also column 3 would be updated automatically in those cases.
现在,我想设置数据,以便在这种情况下也可以自动更新第3列。
What is the right formula to make that happen? 实现这一目标的正确公式是什么?
If you slightly rearrange your worksheet, then the VLOOKUP()
function can be used. 如果您稍微重新排列工作表,则可以使用
VLOOKUP()
函数。 I swapped your A
and B
(first and second) columns to arrive at this: 我交换了您的
A
和B
(第一和第二)列以得出此信息:
--- A ---- B ---- C --- D
r1: word1 0001
r2: word2 0002 0001 word1
r3: word3 0003 0002 word2
Enter into C1
: 输入
C1
:
=VLOOKUP(D1, A$1:B$3, 2, FALSE)
and copy this formula down the C
column. 并将此公式复制到
C
列中。
The reason for swapping the first two columns is that VLOOKUP()
always looks in the first column for the match. 交换前两列的原因是
VLOOKUP()
总是在第一列中查找匹配项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.