excel:如果包含一个文本string,如何返回整个单元格

我有一个大的专栏,每行都有句子。

如果他们包含一个特定的单词,我想要一个接一个地返回句子列表。 例如,在下面的文本中,这是一列,我想复制整个单元格,如果它包含“ ”。

Whan that aprill with his shoures soote The droghte of march hath perced to the roote, And bathed every veyne in swich licour Of which vertu engendred is the flour; Whan zephirus eek with his sweete breeth Inspired hath in every holt and heeth Tendre croppes, and the yonge sonne Hath in the ram his halve cours yronne, And smale foweles maken melodye, That slepen al the nyght with open ye (so priketh hem nature in hir corages); Thanne longen folk to goon on pilgrimages, And palmeres for to seken straunge strondes, To ferne halwes, kowthe in sondry londes; And specially from every shires ende Of engelond to caunterbury they wende, The hooly blisful martir for to seke, That hem hath holpen whan that they were seeke. 

非常感谢

使用Filter或VBA更容易,但是如果你必须有一个公式,你可以试试这个:

 B1: =IF(IFERROR(SEARCH("hath",A1),FALSE),A1,"") B2: =CONCATENATE(B1,IF(IFERROR(SEARCH("hath",A2),FALSE),A2,"")) 

selectB2并填写到B800。 B800将包含您的连接句子。

如果您想在每个句子之间显示一个换行符,请尝试:

 B2: =CONCATENATE(B1,IF(B1<>CONCATENATE(B1,IF(IFERROR(SEARCH("hath",A2),FALSE),A2,"")),CHAR(10),""),IF(IFERROR(SEARCH("hath",A2),FALSE),A2,"")) 

记得打开Wrap Text,你可能需要改变字体大小才能看到所有的字符。

但是请记住,根据连接字符的数量,可能会遇到单元格内容限制的长度。