How to find a value in an excel column by vba code Cells.Find

calendar_today Asked Feb 18, 2013
thumb_up 26 upvotes
history Updated April 16, 2026

Question posted 2013 · +20 upvotes

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

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

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

Accepted answer +26 upvotes

Just use

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

Excel VBA objects referenced (3)

  • Cells.Find — Find All the Sparklines on a Sheet
  • Cells.Find — Find a record in a dynaset-type or snapshot-type DAO Recordset
  • Selection — Working with the Selection Object

Top excel-vba Q&A (6)

+26 upvotes ranks this answer #14 out of 136 excel-vba solutions on this site — top 10%.