在excel中查找单词
您知道,当您单击control-F查找单词时,然后单击find all时,它会显示包含该单词的所有单元格的列表 我们怎么能把它放在一个公式里,这样它就能把这些结果列在一张纸上 假设我有这张表1在excel中查找单词,excel,excel-formula,Excel,Excel Formula,您知道,当您单击control-F查找单词时,然后单击find all时,它会显示包含该单词的所有单元格的列表 我们怎么能把它放在一个公式里,这样它就能把这些结果列在一张纸上 假设我有这张表1 A | B 1 apple 第2页 A | B 1 apple cider 2 peas 3 cucumber 4 apple 5 apple rum 6 carrots 7 beans 8 carrots and apples 我希望结果出来
A | B
1 apple
第2页
A | B
1 apple cider
2 peas
3 cucumber
4 apple
5 apple rum
6 carrots
7 beans
8 carrots and apples
我希望结果出来
A | B | C | D
1 apple apple cider apple rum carrots and apples
尝试在公式栏中键入以下内容:
FIND(expression, text_value)
并通过以下链接:
http://www.smartsheet.com/help-categories/formulas
使用
例如:
Cells.Find(What:="Cat", After:=ActiveCell, LookIn:=xlValues, LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
在模块中编写此函数:
Public Function WordFinder(searchRange As Range, seekWord As String, iteration As Integer)
Dim rangeCell As Range 'holder cell used in For-Each loop
Dim rangeText As String 'holder for rangeCell's text
Dim counter As Integer
counter = 0
'loop through cells in the range
For Each rangeCell In searchRange.Cells
rangeText = rangeCell.Value 'capture the current cell value
'check if the seek word appears in the current cell
If InStr(rangeText, seekWord) > 0 Then
counter = counter + 1 'increment the occurrence counter
If counter = iteration Then 'this is the occurrence we're looking for
'return it
WordFinder = rangeText
Exit Function
End If
End If
Next rangeCell
WordFinder = "n/a" 'that occurrence number was not found
End Function
在结果表的顶行,在每个单元格中输入以下公式:
=wordfinder(Sheet2!$A1:$A8,"apple",column())
column()
随着每一列的增加而增加,因此当您将其复制/粘贴到最上面一行时,它将计数。美元符号确保参考号绝对保留在A列
第二个参数(“苹果”)可以来自一个单元格,尽管我在这里硬编码了它
可能有一种更优雅的方法可以做到这一点,但这是一种快速且肮脏的方法,应该可以使用。我必须手动查找值。谢谢你的回复,我在发布问题之前尝试过这种方法,但没有用,或者可能我不理解它是如何在任何情况下工作的。这有什么帮助吗?谢谢你的回复,我试过了,但是没有用,或者我不明白它是怎么工作的。谢谢你的回复,我试过了,但是我需要更多地玩一下。你能解释一下这是什么意思吗?此外,如果它对您有效,如果您能够批准该解决方案,那就太好了。谢谢
=wordfinder(Sheet2!$A1:$A8,"apple",column())