在Excel中,你如何find文本列表中存在的文本select?

另一个优秀的问题下面的一些很大的帮助,我得到了一个类似的查询,说我有一些文本是URL的一部分说:

example-text 

那么我想要的公式的输出结果在一个很长的URL列表中find是否出现“example-text”,然后如果从search列表中返回完整的URL? 说:

 www.lalala/example-text/lala/random.com 

如果有人能为我解决这个问题,会很好吗?

添加:

哦,我明白了,再次感谢。 是的,我不认为我解释得不够好,我会有另一个刺:说我有一个很长的URL列表,我希望能够看到“示例文本”是否发生在url,然后如果是这样的话,forumla输出itslef是包含“示例文本”的url..是可行的吗? 谢谢。 爱德华

尝试查找文档function:

 =IF(ISERROR(FIND(A2,A1,1)),"Not in the url",A1) 

(假设你的url是在A1和单元格A2example-text

下面是一个VBA用户定义的函数,可以用来返回包含search文本的列表中的第一个项目。 只需在VBA编辑器窗口的新模块中input此代码(Alt + F11打开VBA编辑器)即可。

 Public Function FIRSTWITHIN(lookfor As String, lookin As Variant) As String Dim tmparray() As Variant Dim firstmatch As String firstmatch = "No matching URL found." 'Feeds lookin into temporary array. Error Handler handles case where lookin is a range. 'This allows use of function in array formula. On Error GoTo ErrHandler tmparray = lookin 'Looks through array column by column for match. Returns first match found. For j = 1 To UBound(tmparray, 2) For i = 1 To UBound(tmparray, 1) If InStr(tmparray(i, j), lookfor) > 0 Then firstmatch = tmparray(i, j) Exit For End If Next i If firstmatch <> "No matching URL found." Then Exit For End If Next j FIRSTWITHIN = firstmatch Exit Function ErrHandler: tmparray = lookin.Value Resume Next End Function 

然后你可以使用如下的函数:

 =FIRSTWITHIN("example-text",A2:A20) 

其中A2:A20是您要search的URL列表。