Find

G

Guest

Hello,

I currently use the standard vba code to find specific
cells (data, words) within a spreadsheet.

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

My problem is when the information is not in the
spreadsheet I get an error. How could I rephrase my code
not give me an error if the information is not in the
sheet (in this case the wording "NEW1" is not in the
sheet.)


Thank You,
 
P

Peter Beach

Hi,

Try:

Dim r As Range
Set r = Selection.Find( . . . .)
if not r is nothing then
do your stuff . . .
End If

HTH

Peter Beach
 
Top