在excel中找到单词

时间:2012-11-14 13:54:22

标签: 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       |     C       |    D 
1 apple        apple cider   apple rum    carrots and apples 

4 个答案:

答案 0 :(得分:1)

尝试在公式栏中输入:

FIND(expression, text_value)

并通过此链接:

http://www.smartsheet.com/help-categories/formulas

答案 1 :(得分:1)

将此功能写入模块:

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栏上。

第二个参数(“apple”)可以来自一个单元格,虽然我在这里进行了硬编码。

可能有更优雅的方式来做到这一点,但这是一个快速的&肮脏的方式,应该工作。

答案 2 :(得分:0)

要搜索使用Find()

    expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)

示例:

     Cells.Find(What:="Cat", After:=ActiveCell, LookIn:=xlValues, LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)

答案 3 :(得分:0)

我必须手动查找值。