简体   繁体   中英

excel: Find value in column where cells contain multiple values separated by commas and return value from an adjacent column

I have two tables of data, call them table 1 and 2. In table 1 there is a long list of reference numbers. Each reference number has its own cell.

In table 2 I have the exact same reference numbers; however, in table 2 these reference numbers may or may not share that cell with another reference number. See below. The bottom three reference numbers in table 1 all share the same cell and are separated by a comma always.

Imagine table 1 and 2 are on separate tabs of the same workbook.

table 1 and 2

On the work sheet for table 1, I am trying to bring back the month found adjacent to the reference number in table 2. I am trying to take the value in table 1, search it in table 2, and return the month so that I get this result:

result in column b of table 1

I would like to avoid delimiting the values in the shared cells of table 2.

Thanks in advance for your help!

If your reference number are unique, you can get by with doing a wildcard vlookup Assume you have a range in columns F and G where your reference numbers and months are. In Range A:B you want the values.

Essentially you are looking up like this. If my value A1 is in column F and it matches a substring get the value from G

So you would use this formula in B1

=VLOOKUP(CONCATENATE("*", A1, "*"),$F$1:$G$6,2, FALSE)

what this is doing is, get the value from A1, and match the range of F:G where the first column CONTAINS A1, get the value from the corresponding G column From there copy paste the formula for the rest of the cells in B column

在此处输入图片说明

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.

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