#1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find First Non blank cell than find column header and return that value Silver Rose Excel Worksheet Functions 10 April 30th 07 05:56 PM
where to put results of find operation in find and replace functio DEP Excel Worksheet Functions 5 November 15th 06 07:52 PM
Despite data existing in Excel 2002 spreadsheet Find doesn't find AnnieB Excel Discussion (Misc queries) 1 June 16th 06 02:15 AM
'find' somtimes can't find numbers. I folowd the 'help' instructi. Yaron Excel Worksheet Functions 2 November 30th 05 05:46 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM


All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"