简体   繁体   English

Excel查找列表部分匹配

[英]Excel Lookup list partial match

I have 2 sheets. 我有两张。

Sheet 1 is the work sheet: 工作表1是工作表:

SONY KDL55W805CBAEP LED TV (Flat, 55 Zoll, FullHD, 3D, SMART TV, Android TV)
SONY KDL75W855CBAEP LED TV (Flat, 75 Zoll, FullHD, 3D, SMART TV, Android TV)
SONY KDL48W705CBAEP LED TV (Flat, 48 Zoll, FullHD, SMART TV)
SONY KD43X8305CBAEP LED TV (Flat, 43 Zoll, UHD 4K, SMART TV, Android TV)
SONY KDL50W756C LED TV (Flat, 50 Zoll, FullHD, SMART TV, Android TV)

Sheet 2 contains the full model reference numbers: 表格2包含完整的模型参考编号:

KDL55W805CBAEP
KDL75W855CBAEP
KDL48W705CBAEP
KD43X8305CBAEP
KDL50W756CBAEP

I'm using =IFERROR(LOOKUP(2^15;SEARCH(Sheet2!$B$1:$B$114;Sheet1![Row #]),Sheet2!$B$1:$B$114);"") 我正在使用=IFERROR(LOOKUP(2^15;SEARCH(Sheet2!$B$1:$B$114;Sheet1![Row #]),Sheet2!$B$1:$B$114);"")

Everything gets match as long as the text in Sheet 1 is a 100% match. 只要工作表1中的文本为100%匹配,所有内容都将匹配。 But as soon as it isn't I don't get a match. 但是,一旦不是,我就没有比赛。

For example. 例如。

Sheet 1: 表格1:

SONY KDL50W756C LED TV (Flat, 50 Zoll, FullHD, SMART TV, Android TV)

Sheet2: 工作表2:

KDL50W756CBAEP

How can I make those match aswell? 我也该如何进行匹配?

EDIT: 编辑:

This is sheet 1: 这是表1:

工作表1

This is sheet 2: 这是工作表2:

So in column item_model I want the full model reference. 因此,在item_model列中,我需要完整的模型参考。 But as not all references in Sheet 1 match 100% with Sheet 2 I have a problem 但是,因为工作表1中的所有参考并非都与工作表2中的100%匹配,所以我遇到了问题

工作表2

Use this formula if the Model number is always the second "Word": 如果型号始终是第二个“单词”,请使用以下公式:

=IFERROR(INDEX(Sheet2!B:B,MATCH(TRIM(MID("*" & SUBSTITUTE(B2," ",REPT(" ",99)),99,99)) & "*",Sheet2!B:B,0)),"")

在此处输入图片说明


EDIT: In Dutch, I think 编辑:在荷兰,我认为

=ALS.FOUT(INDEX(Sheet2!B:B;VERGELIJKEN(SPATIES.WISSEN(MIDDEN("*" & SUBSTITUEREN(B2;" ";HERHALING(" ";99));99;99)) & "*";Sheet2!B:B;0));"")

I may have some typos or missing ) 我可能有错别字或缺少)

=IFERROR(INDEX($B$1:$B$6,IF(AGGREGATE(14,6,(ISNUMBER(SEARCH(C1,$A$1:$A$6))*ROW(A1:A6)),1),AGGREGATE(14,6,(ISNUMBER(SEARCH(C1,$A$1:$A$6))*ROW(A1:A6)),1),-1)),"not found")

You will have to update the ranges to suit your needs. 您将必须更新范围以适合您的需求。

C1 what you are looking for. C1您在寻找什么。
First A1:A5 what you are looking in. 首先您要查看的是A1:A5。
B1:B6 what you want to return. B1:B6您想退还什么。
Row(A1:A5) is acting as a counter and may need adjusting if your data is not in the first row. Row(A1:A5)充当计数器,如果您的数据不在第一行中,则可能需要调整。

Tossed in some error generation and checking in case the item you were looking for is not in the list. 抛出一些错误,并检查要查找的项目不在列表中。

概念证明

This will work as long as what you are searching for is not so short as to be found partially after the start in the string. 只要您要搜索的内容不短到在字符串开头部分就可以找到它,它就可以工作。 if you loosk at my example if you searked for K it would toss in the result from row 6 because K is found within the text in A6 如果您在我的示例中不满意,如果您弯腰寻找K,则会在第6行中抛出结果,因为在A6的文本中找到了K

In light of the edits 根据修改

=IFERROR(INDEX($B$1:$B$6,IF(AGGREGATE(14,6,(ISNUMBER(SEARCH(MID(C1,FIND(" ",C1)+1,FIND(" ",C1,FIND(" ",C1)+1)-FIND(" ",C1)-1),$A$1:$A$6))*ROW(A1:A6)),1),AGGREGATE(14,6,(ISNUMBER(SEARCH(MID(C1,FIND(" ",C1)+1,FIND(" ",C1,FIND(" ",C1)+1)-FIND(" ",C1)-1),$A$1:$A$6))*ROW(A1:A6)),1),-1)),"not found")

This assumes what you are searching for is always between the first and second space in the item name. 这假定您要搜索的内容始终位于项目名称的第一和第二个空格之间。

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

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