繁体   English   中英

excel:如果包含文本字符串,如何返回整个单元格

[英]excel : how to return the entire cell if it contains a text string

我有一栏很大,每一行都包含句子。

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

    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.

谢谢很多人

使用过滤器或VBA容易得多,但是如果必须具有公式,则可以尝试以下操作:

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

选择B2并填写至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,""))

记住要打开“自动换行”,并且可能需要更改字体大小才能查看所有字符。

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

暂无
暂无

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

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