[英]Find word plus additional characters in Excel cell
I have an excel sheet with text in a cell - I'd like to extract the specific text and an additional 5 characters alongside it. 我有一个Excel表格,该表格的单元格中有文字-我想提取特定文字和旁边的5个字符。
For example: 例如:
Cell A1 contains the text - 'Here is the cell for widget 1A1A and its content'. 单元格A1包含文本-“此处是窗口小部件1A1A及其内容的单元格”。 I'd like to find any cell that contains the word 'widget' and extract that and the following 5 characters (including space).
我想找到任何包含单词“ widget”的单元格,并将其和以下5个字符(包括空格)提取出来。 So the result would be 'Widget 1A1A'.
因此,结果将是“小部件1A1A”。
This is quite straightforward. 这很简单。 Use the SEARCH command to find the word "widget" (FIND is the same but case-sensitive):
使用SEARCH命令查找单词“ widget”(FIND相同,但区分大小写):
=SEARCH("widget",A1)
This gives you the character number in the cell where the match is found [if no match is found it returns "#N/A". 这会在找到匹配项的单元格中为您提供字符编号[如果找不到匹配项,则返回“#N / A”。
Then match this with the MID function to pull in the text "Widget" + the following 5 characters, as follows: 然后将其与MID函数匹配,以输入文本“窗口小部件”和以下5个字符,如下所示:
=MID(A1,SEARCH("widget",A1), LEN("widget") + 5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.