计算另一个单元格中文本段落中单词出现的实例

count instances of occurrence of word from paragraphs of text in another cell

我想统计 name/keyword 在一篇文章中被使用了多少次

Page    Contain check
Page 1  sfdsd
Page 2  This is Service 1 and Service 2
Page 3  sfdsd
Page 4  fsdf
Page 5  This is Service 1 
Page 6  Service 2 is on sale
Page 7  sdf
Page 8  Service 2 is good

我尝试使用 countif 公式 =countif(A:A,F:F) 但没有给出结果

=countif(A:A,F:F)

预期结果如下x

Names      Expected Result
Service 1   2
Service 2   3
Service 3   0

"姓名可以在一个单元格中计数两次。

e.g. 'Service 1' is featured, please check more features of 'Service1' below"

因此在这种情况下,服务 1 被计为 2 次

假设您有以下命名范围:

  • Contain_check 是包含名称
  • 的字符串列表

假设姓名在A2:A4范围内,您可以在单元格B2中使用以下公式来计算姓名出现的次数并向下拖动以跨过应用:

=SUMPRODUCT(LEN(Contain_check)-LEN(SUBSTITUTE(Contain_check,A2,"")))/LEN(A2)

替换 A2 以适合您的情况。

The logic is to use SUBSTITUTE function to remove the target name from the strings, use LEN function to compare the string length before and after removing the target name, divide the difference by the length of the name will give you the "count" of the target name from each string, and lastly use SUMPRODUCT function to add up the counts.

*请注意,在您的示例 'Service 1' is featured, please check more features of 'Service1' below" 中,Service 1 之间有一个 space,而 Service1 之间没有 space,因此从技术上讲,它们是两个不同的名称,每个名称只计算 return 个,但不计算 2。请说明是否要将 Service 1Service1 视为同名?