vba 查找 A 列中的值是否包含 B 列中的值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11315551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 13:26:54  来源:igfitidea点击:

Find if value in column A contains value from column B?

excelvbaexcel-vbaexcel-2007

提问by Nemo

I have two columns- column E which extends upto 99504(values) and column I which extends to 2691(values).Both the columns contains filenames with extension.

我有两列 - E 列扩展到 99504(值)和 I 列扩展到 2691(值)。这两列都包含带扩展名的文件名。

Something like this

像这样的东西

E               I
TSL_groups.mrk  pcbx_report.mrk
abcd.mrk        jhuo.mrk

and so on...

等等...

I want to find if the files in column I (heading Filename_B) exists in column E(heading Filename_A). If true, say TRUE in a new column let's say column K.

我想查找列 I(标题 Filename_B)中的文件是否存在于列 E(标题 Filename_A)中。如果为真,则在新列中为 TRUE,假设为 K 列。

How do I do that? TIA.

我怎么做?TIA。

回答by Brad

You could try this

你可以试试这个

=IF(ISNA(VLOOKUP(<single column I value>,<entire column E range>,1,FALSE)),FALSE, TRUE)

-or-

-或者-

=IF(ISNA(VLOOKUP(<single column I value>,<entire column E range>,1,FALSE)),"FALSE", "File found in row "   & MATCH(<single column I value>,<entire column E range>,0))

you could replace <single column I value>and <entire column E range>with named ranged. That'd probably be the easiest.

你可以用命名的 ranged替换<single column I value><entire column E range>。那应该是最简单的了。

Just drag that formula all the way down the length of your I column in whatever column you want.

只需将该公式一直拖到您想要的任何列中的 I 列的长度即可。

回答by JimmyPena

You can use VLOOKUP, but this requires a wrapper function to return Trueor False. Not to mention it is (relatively) slow. Use COUNTIF or MATCH instead.

您可以使用 VLOOKUP,但这需要一个包装函数来返回TrueFalse。更不用说它(相对)慢。请改用 COUNTIF 或 MATCH。

Fill down this formula in column K next to the existing values in column I (from I1to I2691):

在 I 列中现有值旁边的 K 列中填写此公式(从I1I2691):

=COUNTIF(<entire column E range>,<single column I value>)>0
=COUNTIF($E:$E504,$I1)>0

You can also use MATCH:

您还可以使用 MATCH:

=NOT(ISNA(MATCH(<single column I value>,<entire column E range>)))
=NOT(ISNA(MATCH($I1,$E:$E504,0)))

回答by taosio

You can try this. :) simple solution!

你可以试试这个。:) 简单的解决方案!

=IF(ISNUMBER(MATCH(I1,E:E,0)),"TRUE","")