如何将Excel中的返回值更改为特定单元格的内容?

huangapple go评论74阅读模式
英文:

How to change the return value in Excel to the content of a specific cell?

问题

=如果(计数(Sheet2!L:L;B6 & "," & C6) > 0; Sheet2!K:K; "")
英文:
=IF(COUNTIF(Sheet2!L:L;B6 & "," & C6) > 0; "x"; "")

Columns B and C contains last and first name of employees (B6 = Cook, C6 = Jim).
In row L of Sheet2 is the same content, but its in one single row divided by a comma (eq. Cook, Jim).
The formula compares the 2 sheets until it finds a match. Now I want the formula the return the value of a cell in the same line where the match was found. The cell contains the employees ID and is located in row K.

For example if the name from B6:C6 is found in Sheet2 in row L28, then the formula should return the employees ID from K28 and if B6:C6 is found in row L200 then the return value is K200.

如何将Excel中的返回值更改为特定单元格的内容?

答案1

得分: 2

Here is the translated content:

简单的 VLOOKUP: 使用连接字符串应该可以工作:

=IFERROR(VLOOKUP(A2&","&B2,Sheet2!A:B,2,FALSE),"未找到")

结果:

如何将Excel中的返回值更改为特定单元格的内容?

可以使用 TRIM: trimTRIMCLEAN 的组合:clean,以避免由于前导、尾随空格和不可打印字符引起的错误:

=IFERROR(VALUE(VLOOKUP(CLEAN(TRIM(A2))&","&CLEAN(TRIM(B2)),CLEAN(TRIM(Sheet2!$A$1:$B$4)),2,FALSE),"未找到")

请注意,在此情况下使用了数据的确切范围 Sheet2 ($A$1:$B$4 而不是 A:B),以避免减慢 Excel 的速度。

英文:

Simple VLOOKUP: vlookup with concatenated string should work:

=IFERROR(VLOOKUP(A2&","&B2,Sheet2!A:B,2,FALSE),"Nor found") 

Result:

如何将Excel中的返回值更改为特定单元格的内容?

Could use TRIM: trim or combination of TRIM and CLEAN: clean in addition to avoid errors caused by leading, trailing spaces and unprintable characters:

=IFERROR(VALUE(VLOOKUP(CLEAN(TRIM(A2))&","&CLEAN(TRIM(B2)),CLEAN(TRIM(Sheet2!$A$1:$B$4)),2,FALSE)),"Not found")

Note that exact range of data in Sheet2 ($A$1:$B$4 instead of A:B) is used in this case to not slow Excel down.

huangapple
  • 本文由 发表于 2023年5月22日 16:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76304247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定