使用IF从另一个表复制列

时间:2022-09-15 21:08:49

I have 2 sheets, let's say column A is item ID, column B is owner of the item. In the first sheet the column B is empty, so I need to copy column B from another sheet. I don't know if they are both ordered the same, probably yes, they appear they might be. I used IF function, IF cell-ID in the first sheet is equal to cell-ID in the second sheet and the cell-owner in the second sheet is not empty then cell-owner in the first sheet is equal to the one in the second sheet. How would I make sure that this function would work even if the order of data was different?

我有两张表,假设A列是项目ID, B列是项目的所有者。在第一张表中,B列是空的,所以我需要从另一张表中复制B列。我不知道它们的顺序是否一样,可能是的,它们看起来可能是一样的。我使用IF函数,如果第一个表中的单元格id等于第二个表中的单元格id而第二个表中的单元格所有者不是空的那么第一个表中的单元格所有者就等于第二个表中的单元格所有者。我如何确保即使数据的顺序不同,这个函数也能正常工作?

EDIT: I just thought of one solution to order both sheets according to ID and then use IF function, but how else could I solve this?

编辑:我想了一个解决方案,根据ID对两个表进行订购,然后使用IF函数,但我还能怎么解决这个问题呢?

2 个解决方案

#1


1  

Use VLOOKUP:

使用VLOOKUP:

=VLOOKUP(A2, Sheet2!A2:B4, 2)

Assumptions:

假设:

  • Enter this formula into the owner column B of the first sheet
  • 将此公式输入第一个表的owner列B中
  • A2 is an itemID from the first sheet
  • A2是第一张表的itemID。
  • Sheet2!A2:B4 contains both the itemID and owner from the second sheet
  • Sheet2 !A2:B4包含来自第二页的itemID和owner

#2


0  

You are looking for VLOOKUP

您正在查找VLOOKUP

One tutorial for how to use it here

这里有一个如何使用它的教程

It matches the ID number and gives you the specified column value

它匹配ID号并给出指定的列值

for example you might want something like:

例如,你可能想要:

=VLOOKUP(Sheet1!cellID, Rng, 2)

This matches the ID and gives you the 2nd column entry corresponding to that ID from the other Sheet. Rng is the table where you have your data, for example A1:B500. Hope this helps!

它匹配ID并给出与另一个表中的ID对应的第二列条目。Rng是您拥有数据的表,例如A1:B500。希望这可以帮助!

#1


1  

Use VLOOKUP:

使用VLOOKUP:

=VLOOKUP(A2, Sheet2!A2:B4, 2)

Assumptions:

假设:

  • Enter this formula into the owner column B of the first sheet
  • 将此公式输入第一个表的owner列B中
  • A2 is an itemID from the first sheet
  • A2是第一张表的itemID。
  • Sheet2!A2:B4 contains both the itemID and owner from the second sheet
  • Sheet2 !A2:B4包含来自第二页的itemID和owner

#2


0  

You are looking for VLOOKUP

您正在查找VLOOKUP

One tutorial for how to use it here

这里有一个如何使用它的教程

It matches the ID number and gives you the specified column value

它匹配ID号并给出指定的列值

for example you might want something like:

例如,你可能想要:

=VLOOKUP(Sheet1!cellID, Rng, 2)

This matches the ID and gives you the 2nd column entry corresponding to that ID from the other Sheet. Rng is the table where you have your data, for example A1:B500. Hope this helps!

它匹配ID并给出与另一个表中的ID对应的第二列条目。Rng是您拥有数据的表,例如A1:B500。希望这可以帮助!