如何在 Excel "table" 中搜索值?

How to search for values in Excel "table"?

如果我有这个 table:

a,6,10,22,35,46
b,2,7,11,23,44,78
c,2,10,15,16,32,66,98
d,7,8,10,11,23,25,30
e,23,24

现在我想搜索某个值的出现次数和 returns 每个对应行第一列的值。

所以 2 给出:b,c23 给出 b,d,e.

喜欢:

2,b,c
23,b,d,e

是否可以通过使用 VLOOPUP- 或其他函数来实现?

谢谢!

如果我理解正确,并且Column与,一致并且没有间距,那么我制作的公式如下:

=IF(ISNUMBER(SEARCH(",23,",A1)),"23,b,d,e",IF(ISNUMBER(SEARCH(",2,",A1)),"2,b,c","N/A"))

假设 a,6,10,22,35,46A1 中,例如,您可以将其粘贴到 B1 中并向下拖动公式。这将为您提供您在示例中寻找的结果。

我用这个公式得到的答案:

关于 IF(ISNUMBER(SEARCH 公式的文档:https://exceljet.net/formula/if-cell-contains

希望这对您有所帮助,

-美琪

如果您对 解决方案持开放态度,则可以创建自己的函数:

只需确保将其插入新模块

Option Explicit

Public Function INCOLUMNS(ByVal value As String, ByVal searchrange As Range) As String

    Dim res As String
    Dim i As Long
    Dim temp As Range

    For i = 1 To searchrange.Columns.Count
        Set temp = Range(Cells(1, i), Cells(searchrange.Rows.Count, i)). _ 
                   Find(value, LookIn:=xlValues, LookAt:=xlWhole)
        If Not temp Is Nothing Then
            If res = "" Then
                res = Split(Cells(1, i).Address, "$")(1)
            Else
                res = res & ", " & Split(Cells(1, i).Address, "$")(1)
            End If
        End If
    Next i

    INCOLUMNS = res
End Function

然后你可以像这样在 Worksheet 中使用它: