Anthony
Anthony

Reputation: 552

How do I set a column to search in using Excel VBA?

I am trying to carry out a search in Column B only but with the code below the whole worksheet is being searched. How do I change my code to search only column B?

Columns("B:B").Select

                Cells.Find(What:=Region, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
                    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                        False, SearchFormat:=False).Activate

Upvotes: 0

Views: 43

Answers (1)

Egan Wolf
Egan Wolf

Reputation: 3573

Columns("B:B").Find(What:=Region, After:=Range("B1"), LookIn:=xlFormulas, LookAt _
                :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False).Activate

Upvotes: 1

Related Questions