简体   繁体   English

计算Excel中单元格中单词的出现

[英]Count occurrence of words in cell in Excel

I am using Microsoft Excel 2013. I have a entire sentence in one of the cell in my Excel spreadsheet. 我正在使用Microsoft Excel2013。我的Excel电子表格中的一个单元格中有一个完整的句子。 I want to count instance of several words in that cell. 我想计算该单元格中几个单词的实例。

Example: Say the sentence " He is not doing very well. His scores have been dropping consistently over the last few months. I spoke to him about his scores. I have also recommended several actions." 示例:说出一句“ 表现不佳。过去几个月他的分数一直在下降。 介绍了他的分数。 还建议了一些措施。” exists in cell A2. 存在于单元格A2中。

I want to count the instances of words "he","his","I","him" in the sentence. 我想计算句子中单词“ he”,“ his”,“ I”,“ him”的实例。

So the cell B2 would have a count of 6. 因此,单元格B2的计数为6。

How do I do this? 我该怎么做呢?

根据XOR LX关于替换所有标点符号的建议,单元格B2中的公式如下所示:

=SUMPRODUCT((LEN(" "&A2&" ")-LEN(SUBSTITUTE(" "&LOWER(A2)&" "," "&{"he","his","i","him"}&" ","")))/LEN(" "&{"he","his","i","him"}&" "))

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

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