[英]excel : how to return the entire cell if it contains a text string
I have a big column, containing sentences in each row. 我有一栏很大,每一行都包含句子。
I want to return the list of sentences, one after another if they contain a specific word. 我想返回句子列表,如果它们包含特定单词,则一个接一个地返回。 For example, in the following text, which is one column, I want to copy the entire cell if it contains " hath " .
例如,在下面的一栏文字中,如果它包含“ 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.
thank alot guys 谢谢很多人
Much easier to do with a Filter, or with VBA, but if you must have a formula, you can try this: 使用过滤器或VBA容易得多,但是如果必须具有公式,则可以尝试以下操作:
B1: =IF(IFERROR(SEARCH("hath",A1),FALSE),A1,"")
B2: =CONCATENATE(B1,IF(IFERROR(SEARCH("hath",A2),FALSE),A2,""))
Select B2 and fill down to B800. 选择B2并填写至B800。 B800 will contain your concatenated sentences.
B800将包含您的级联句子。
If you want to show a newline between each sentence, then try: 如果要在每个句子之间显示换行符,请尝试:
B2: =CONCATENATE(B1,IF(B1<>CONCATENATE(B1,IF(IFERROR(SEARCH("hath",A2),FALSE),A2,"")),CHAR(10),""),IF(IFERROR(SEARCH("hath",A2),FALSE),A2,""))
Remember to turn on Wrap Text, and you may need to change the font size in order to see all the characters. 记住要打开“自动换行”,并且可能需要更改字体大小才能查看所有字符。
But also remember that, depending on the number of characters in your concatenation, you may run into the length of cell contents limitation. 但也请记住,根据连接中字符的数量,您可能会遇到单元格内容长度的限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.