MS Excel wildcard lookup

你说的曾经没有我的故事 提交于 2020-01-06 04:42:09

问题


I have a lookup table in Excel with ColA and ColB :

ColA    ColB   ColC
va       1     value1

ColC is the actual value table

I need to do a wildcard lookup with lookup_value = "value1" I need to perform an operation that if the value of ColC matches the characters in ColA then it should return me ColB value, i.e. 1

I want to use wildcards in the lookup function to achieve this result. Any help will be appreciated! Thanks


回答1:


You can use wildcards with VLOOKUP. You'll have to rearrange your table so that the lookup column is the first column, but other than that it should work. I put:

abc 1
def 2
ghi 3
jkl 4

into a range named "table"

Then:

g*
g?i
?kl

into F2:F4

Now, in G2:G4, I put this formula:

=VLOOKUP(F2,table,2,FALSE)

and it correctly found 3 in cells G2 & G3, and 4 in cell G4.

The asterisk means zero or more characters; the question mark means exactly one character.




回答2:


This works as a wild card with text strings:

=vlookup("*"&REF&"*",lookup range, column,  false)

It turns a number into text to do a wild card on a number. Stars should go between the quotations but they are not showing up.




回答3:


You can do it this way:

=VLOOKUP(LOOKUP("value1",ColC:ColC,ColC:ColC), lookuprange, COLUMN(ColA) + 1, TRUE)

Of course you can simplify this with your domain knowledge.

This method allows you to use your lookup table as is.



来源:https://stackoverflow.com/questions/1208363/ms-excel-wildcard-lookup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!