Range.Find in VBA Excel

前端 未结 2 1811
天命终不由人
天命终不由人 2021-01-27 08:49

I\'m trying to perform a \"find\" in a Excel sheet with this instruction:

Set Found = Columns(2).Find(What:=value_to_find, After:=ActiveCell, LookIn:=xlFormulas,         


        
2条回答
  •  难免孤独
    2021-01-27 09:14

    Exactly as @barrowc commented.

    This works although not sure of exact requirements:

    Sub xxx()
    
    Dim value_to_find As String
    value_to_find = "fooBar"
    
    Dim r As Range
    Set r = ActiveCell.EntireColumn.Find( _
        What:=value_to_find, _
        After:=ActiveCell, _
        LookIn:=xlFormulas, _
        LookAt:=xlPart, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=False, _
        SearchFormat:=False)
    
    MsgBox r.Address
    
    End Sub
    

    enter image description here

提交回复
热议问题