如何通过 vba 代码 Cells.Find 在 excel 列中查找值

如何通过 vba 代码 Cells.Find 在 excel 列中查找值

问题描述:

我必须在 Excel 工作表中找到一个值 celda.我正在使用此 vba 代码来查找它:

I have to find a value celda in an Excel sheet. I was using this vba code to find it:

Set cell = Cells.Find(What:=celda, After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False)


If cell Is Nothing Then
    'do it something

Else
    'do it another thing
End If

问题是当我必须仅在 excel 列中查找值.我用下一个代码找到它:

The problem is when I have to find the value only in a excel column. I find it with next code:

    Columns("B:B").Select
    Selection.Find(What:="VA22GU1", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

但是我不知道如何将它适配到第一个 vba 代码中,因为我必须使用值 nothing.

But I don't know how to adapt it to the first vba code, because I have to use the value nothing.

就用

Dim Cell As Range
Columns("B:B").Select
Set cell = Selection.Find(What:="celda", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

If cell Is Nothing Then
    'do it something

Else
    'do it another thing
End If