Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel:搜索信息_Excel_Worksheet Function - Fatal编程技术网

Excel:搜索信息

Excel:搜索信息,excel,worksheet-function,Excel,Worksheet Function,伙计们,我需要在文本中找到具体的信息,并把它们写在专栏里 因此,我有长描述的列L,我有列M,我需要在长描述中找到单词。找到单词后,将该单词写在列N的同一行作为长描述。 我试着编写了这个,但没用 =INDEX(M1:M4;MAX(IF(ISERROR(FIND(M1:M4;L1));-1,1)*(ROW(M1:M4)-ROW(M1)+1))) 这就是我所说的例子。。请你真的需要帮助 这个UDF应该可以做到这一点-除了您可以在其中看到的注释之外,我不会详细描述它的功能,因为它不是一段非常复杂的代码

伙计们,我需要在文本中找到具体的信息,并把它们写在专栏里

因此,我有长描述的列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
需要,然后将公式输入到希望返回值正常的单元格中:


这个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
需要,然后将公式输入到希望返回值正常的单元格中:


使用工作表函数执行此操作看起来有点复杂。您愿意改用UDF/VBA宏吗?我在那个excel文件中有很多信息。如果VBA代码不会影响其他信息,则这些列将显示。我愿意使用它。如果你能帮上忙的话,用工作表函数做这件事看起来有点复杂。您愿意改用UDF/VBA宏吗?我在那个excel文件中有很多信息。如果VBA代码不会影响其他信息,则这些列将显示。我愿意使用它。如果你能帮上忙的话,用工作表函数做这件事看起来有点复杂。您愿意改用UDF/VBA宏吗?我在那个excel文件中有很多信息。如果VBA代码不会影响其他信息,则这些列将显示。我愿意使用它。要是你能帮忙就好了