简体   繁体   English

如果单元格与另一个单元格匹配,则复制值

[英]If Cell Matches another Cell, Copy Value

I can't seem to figure this one out. 我似乎无法弄清楚这一点。 I have two work sheets with some of the same ids, but if an id matches on one sheet with another I need it to see if the status is Routed and if it is, then I need ay placed in Column B of the related number. 我有两个工作表,其中一些具有相同的ID,但是如果一个表上的ID与另一个表上的ID匹配,我需要它查看状态是否为“已路由”,如果是,则需要在相关编号的B列中放置y。

So for example: 因此,例如:

Worksheet 1  
-----A--------B  
1--**4345**---Routed  
2--5643---Completed  
3--3423---Routed  
4--2342---Routed  



Worksheet 2  
-----A-------B  
1--9876----n  
2--5678----n  
3--**4345**----y  
4--1234----n  

So if there is a match in column A between the two worksheets then I need it to search for Routed in Column B on Worksheet 1. 因此,如果两个工作表之间的A列中都存在匹配项,那么我需要它在工作表1的B列中搜索Routed。

If the word Routed is there, then I need it to add a "y" to the previously matched id in column B of Worksheet 2, otherwise if the id is not found or if it matches, but no routed (rather it be blank or something else [completed, done, ect]) then I need an n in column B. 如果存在路由一词,那么我需要它在工作表2的B列中先前匹配的ID上添加一个“ y”,否则,如果找不到该ID或它与之匹配但没有被路由(则为空白或其他的东西[完成,完成等]),那么我在B列中需要一个n。

Inserting a VLOOKUP() function into an IF() function will test whether the looked-up value meets the specified condition, and return the specified values if TRUE ( "y" ) or FALSE (" n "): =IF(VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE)="Routed", "y", "n") . VLOOKUP()函数插入IF()函数将测试查找的值是否满足指定的条件,如果是TRUE"y" )或FALSE (“ n ”),则返回指定值: =IF(VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE)="Routed", "y", "n") You can enclose the entire formula in IFERROR() to account for IDs in Sheet2 that are not in Sheet1: =IFERROR(IF(VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE)="Routed", "y", "n"), "n") . 您可以将整个公式括在IFERROR()以解决Sheet2中不在Sheet1中的ID: =IFERROR(IF(VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE)="Routed", "y", "n"), "n")

Per comments: If you want to find any cell containing the text "Routed" (but possibly with other text as well), you can change the VLOOKUP(. . .) = "Routed" condition to a test of whether the SEARCH() function finds the text: =IF(ISNUMBER(SEARCH("Routed", VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE))), "y", "n") . 每个注释:如果要查找包含文本"Routed" (但也可能包含其他文本)的任何单元格,则可以将VLOOKUP(. . .) = "Routed"条件更改为测试SEARCH()函数查找文本: =IF(ISNUMBER(SEARCH("Routed", VLOOKUP(A2, SHEET1!$A$1:$B$4, 2, FALSE))), "y", "n") Again, you can enclose this in IFERROR() . 同样,您可以将其包含在IFERROR()

This works. 这可行。 Place the below formula in Sheet2. 将以下公式放在Sheet2中。 You can paste it down as many rows as you like as it is relative. 您可以根据需要将其粘贴到尽可能多的行中。

=IF(NOT(A1=Sheet1!A1),"",IF(Sheet1!B1="routed","y","n"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM