Fork me on GitHub

VBA - 列中查找包含特定文本的单元格

Function FindCellByText(searchRange As Range, searchText As String) As Range
    ' 功能:在指定列中查找包含特定文本的单元格
    ' 参数:
    '   searchRange - 要搜索的列范围
    '   searchText  - 要查找的文本
    ' 返回:找到的单元格对象(若未找到返回Nothing)
    
    Dim foundCell As Range
    Set foundCell = searchRange.Find( _
        What:=searchText, _
        LookIn:=xlValues, _
        LookAt:=xlPart, _
        MatchCase:=False)
    
    Set FindCellByText = foundCell

End Function
posted @ 2025-06-26 17:19  逍遥メ风  阅读(24)  评论(0)    收藏  举报