簡體   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