ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find (https://www.excelbanter.com/excel-programming/303853-find.html)

No Name

Find
 
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,

Peter Beach

Find
 
Hi,

Try:

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

HTH

Peter Beach

wrote in message
...
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,





All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com