Excel:搜索资料
Excel: search for information
伙计们,我需要在文本中找到特定的信息,并将它们写在专栏中。
所以,我有L列详细描述,我有M列以及我需要在 详细说明 中找到的词语。找到单词后,将该单词写在 列 N 与 详细描述 相同的行中。
我试过编码这个但是没用。
=INDEX(M1:M4;MAX(IF(ISERROR(FIND(M1:M4;L1));-1,1)*(ROW(M1:M4)-ROW(M1)+1)))
这是我的意思的示例。请真的需要帮助。
这个 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
您需要 paste the code above into a module in your workbook,然后将公式输入到您希望 return 值正常的单元格中:
伙计们,我需要在文本中找到特定的信息,并将它们写在专栏中。
所以,我有L列详细描述,我有M列以及我需要在 详细说明 中找到的词语。找到单词后,将该单词写在 列 N 与 详细描述 相同的行中。 我试过编码这个但是没用。
=INDEX(M1:M4;MAX(IF(ISERROR(FIND(M1:M4;L1));-1,1)*(ROW(M1:M4)-ROW(M1)+1)))
这是我的意思的示例。请真的需要帮助。
这个 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
您需要 paste the code above into a module in your workbook,然后将公式输入到您希望 return 值正常的单元格中: