简体   繁体   English

Excel中的Vlookup部分编号

[英]Vlookup partial number in Excel

I'm trying to use a vlookup on telephone numbers by looking for the last 8 characters as some are begin 4401 and others just 1. 我正在尝试通过查找最后8个字符在电话号码上使用vlookup,因为某些字符以4401开始,而其他字符仅为1。

This is what I have so far: 这是我到目前为止的内容:

=IFERROR(VLOOKUP("*"&(TRUNC(RIGHT(A3*1,8),0)*1),J:N,5,FALSE),"Unknown")

Column J contains the phone number and column N contains the source of the call (which is what I'm trying to extract). J列包含电话号码,N列包含呼叫来源(这就是我要提取的内容)。

The problem I have is that the iferror 'Unknown' is being returned. 我的问题是,返回了iferror'Unknown'。 If I change the numbers to words then it works, it seems that it's numbers that are the problem. 如果我将数字更改为单词,那么它可以工作,看来问题出在数字。 Any ideas? 有任何想法吗?

Are you willing and able to modify the lookup spreadsheet structure slightly to add a Column K using the formula below in cell K1 and dragging that down?? 您是否愿意并能够略微修改查找电子表格的结构,以使用下面的单元格K1中的公式添加列K并将其向下拖动?

=TEXT(J1,0)

Then your VLOOKUP will now see text instead of numbers. 然后,您的VLOOKUP现在将看到文本而不是数字。 Therefore the wildcard will work. 因此,通配符将起作用。 Just make sure to move your range accordingly (J:N to K:O). 只要确保相应地移动范围(J:N到K:O)即可。

=IFERROR(VLOOKUP("*"&(TRUNC(RIGHT(A3*1,8),0)*1),K:O,5,FALSE),"Unknown")

Edit: If you do not wish to modify your structure (probably best not to but case by case), this array formula will do the job. 编辑:如果您不想修改您的结构(可能最好不要修改,请视情况而定),此数组公式将完成此工作。 Make sure you hit Ctrl+Shift+Enter after entering the formula. 输入公式后,请确保按Ctrl + Shift + Enter。 If you don't, everything will return "Unknown". 如果不这样做,所有内容都将返回“未知”。 Ctrl+Shift+Enter is how Excel knows it is an array function. Ctrl + Shift + Enter是Excel知道它是数组函数的方式。

=IFERROR(INDEX($N:$N,MATCH("y",IF(RIGHT(A3,8)=RIGHT($J:$J,8),"y",),0)),"Unknown")

With this latter method, you may want to set some sort of bound on your $J:$J range in order to speed up the function so it isn't checking every row in that column. 使用后一种方法,您可能需要在$ J:$ J范围内设置某种绑定,以加快该函数的速度,因此它不会检查该列中的每一行。 Pick something bigger than your data will ever be (eg, $J$1:$J$50000). 选择比您的数据更大的东西(例如,$ J $ 1:$ J $ 50000)。

This works for me: 这对我有用:

{=INDEX($N$1:$N$4,MATCH(A3&"",RIGHT($J$1:$J$4,8),0),1)}

You need to enter it as an array formula - so control + enter after keying in the formula. 您需要将其作为数组公式输入 -因此在键入公式后输入Control + Enter

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

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