Excel:search信息

我需要在文本中find具体的信息,并在列中写下来。

所以,我有一个长描述的 列L ,并且列M中有我需要在长描述中find的单词。 当已经find单词时,将该单词写在与长描述相同的行的列N中。 我尝试编码这个,但不是工作。

=INDEX(M1:M4;MAX(IF(ISERROR(FIND(M1:M4;L1));-1,1)*(ROW(M1:M4)-ROW(M1)+1))) 

这是我的意思的示例。Pleaaase真的需要帮助。

在这里输入图像说明

这个UDF应该做的窍门 – 我不会提供一个详细的描述,除了你可以看到它的意见,因为它不是很复杂的一段代码,但如果有什么你不明白的,随时问。

 Option Explicit Function find_keywords(cell_to_search As Range, range_of_keywords As Range) As String Dim c As Range ' Check for the value of each cell in the range of keywords passed to the function For Each c In range_of_keywords ' If the string-value we search for is in the cell we check against, we add it to the return-value If InStr(1, cell_to_search.Text, c.Text, vbTextCompare) > 0 Then ' We don't want a comma before the first keyword we add, so check for the length of the return value If Len(find_keywords) > 0 Then find_keywords = find_keywords & ", " End If find_keywords = find_keywords & c.Text End If Next End Function 

您需要将上面的代码粘贴到工作簿中的模块中 ,然后将公式input到您希望返回值正常的单元格中:

在工作表中使用的公式看起来像什么