简体   繁体   中英

How to match a cell's delimited string with content from another sheet in Excel

Say if I had on one sheet, let's call it S1

 T1  1
 T2  3
 T3  4
 T5  6
 T4  2

And say I have this in a cell in S2

 T1;T2;T3;T4   10

Is it possible to use excel functions to go to S1, find T1, T2, T3, and T4 and sum the values that correspond to them?

So far I have functions capable of searching for one string and pulling data out of it, but I don't know how to do it for delimited strings, or if it's possible to do it at all

=SUMIF('2014'!$B:$B, J9, '2014'!$F:$F)

EDIT: If I do not know the range of my values. Should I just put very large numbers?

If your first table is in S1!A1:B5 and in S2 sheet you have T1;T2;T3;T4 in cell A8 try this formula for the sum

=SUMPRODUCT(ISNUMBER(SEARCH(";"&'S1'!$A$1:$A$5&";",";"&A8&";"))+0,'S1'!$B$1:$B$5)

SEARCH searches for each value from A1:A5 surrounded by ";" signs in A8 , also surrounded by ; signs, if there's a match you get a number so ISNUMBER returns TRUE and SUMPRODUCT adds the relevant value from B1:B5

SEARCH is not case-sensitive - if you need it to be then use FIND instead

See screenshot - shown on one sheet for simplicity but it's the same formula

在此处输入图片说明

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