...我知道您没有要求 VBA 解决方案,但我只是想写一个来看看我会怎么做...
我让它“又快又脏”,没有任何错误检查等,但它会给你你正在寻找的东西:
Public Function FindInRange(Val As Variant, LookIn As Range, ColIndexNumber As Integer) As Range
' INPUTS:
' Val = The Value you're looking for in your Range of cells
' Range = The range of cells you're searching through
' ColIndexNumber = The index of the column you want a value returned from within the row from which the value is found
' NOTE:
' This will only pull the first value matching your "Val" argument
Dim FoundCell As Range
Set FoundCell = LookIn.Find(what:=Val, LookAt:=xlWhole)
If FoundCell Is Nothing Then
Set FindInRange = Nothing
Else
Set FindInRange = Intersect(LookIn.Columns(ColIndexNumber), FoundCell.EntireRow)
End If
End Function
如果将其粘贴到 VBA 模块中,则可以从电子表格中调用它,就像此时的任何其他函数一样。
希望这可以帮助 :)