简体   繁体   English

在Excel中查找字符串的出现

[英]Finding occurences of string in Excel

I have a column in Excel filled with non uniform data and I need to find the occurrences of strings within it. 我在Excel中有一列填充了不统一的数据,我需要查找其中出现的字符串。

Example table: 表格示例:

http://is.gd/RGvXND http://is.gd/RGvXND

Using =COUNTIF(A:A, " "&B2&" ") would work, with the exception of "Apple", which appears twice in the same cell. 使用= COUNTIF(A:A,“ ”&B2&“ ”)可以工作,但“ Apple”例外,它在同一单元格中出现两次。

How do you overcome this problem? 您如何克服这个问题?

How many duplicates can you have? 您可以复制多少张? Use the following formula, updating the row 10 to your maximum number of duplicates. 使用以下公式,将第10行更新为最大重复次数。 Enter using Ctrl + Shift + Enter as this is an array formula. 使用Ctrl + Shift + Enter输入,因为这是一个数组公式。

=SUM(COUNTIF($A$2:$A$7,REPT("*"&$B2&*",ROW($1:$10))))

这是另一个公式选项,但是如果有大量数据,它可能会变慢

=SUMPRODUCT(LEN(A$2:A$10)-LEN(SUBSTITUTE(A$2:A$10,B2,"")))/LEN(B2)

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

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