1

你知道当你点击 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

4 回答 4

1

尝试在公式栏中输入:

FIND(expression, text_value)

并通过此链接:

http://www.smartsheet.com/help-categories/formulas
于 2012-11-14T14:01:46.603 回答
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”)可以来自一个单元格,虽然我在这里硬编码了它。

可能有一种更优雅的方式来做到这一点,但这是一种应该有效的快速而肮脏的方式。

于 2012-11-14T15:30:10.287 回答
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)
于 2012-11-14T14:01:49.943 回答
0

我不得不手动查找这些值。

于 2012-11-21T10:33:56.333 回答