Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default If search criteria is not found, then goto Repeat?

I'm using a macro to search for an item. If the item is not found, then I
receive an error. How can I tell the macro to goto Repeat: if the search
criteria is not found?

This is my search code.

Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=
_
xlNext, MatchCase:=False).Select

Thanks,
Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default If search criteria is not found, then goto Repeat?

Hi Paul
try
Dim rng as range
on error resume next
set rng = Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False)
on error goto 0
if not rng is nothing then
rng.select
end if




--
Regards
Frank Kabel
Frankfurt, Germany

PCLIVE wrote:
I'm using a macro to search for an item. If the item is not found,
then I receive an error. How can I tell the macro to goto Repeat: if
the search criteria is not found?

This is my search code.

Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False).Select

Thanks,
Paul


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default If search criteria is not found, then goto Repeat?

Thanks!

"Frank Kabel" wrote in message
...
Hi Paul
try
Dim rng as range
on error resume next
set rng = Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False)
on error goto 0
if not rng is nothing then
rng.select
end if




--
Regards
Frank Kabel
Frankfurt, Germany

PCLIVE wrote:
I'm using a macro to search for an item. If the item is not found,
then I receive an error. How can I tell the macro to goto Repeat: if
the search criteria is not found?

This is my search code.

Selection.Find(What:=model, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False).Select

Thanks,
Paul




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
search a row for a word and if found Vibeke Excel Worksheet Functions 2 April 16th 10 10:09 AM
Search and Goto Dgwood90 Excel Discussion (Misc queries) 1 September 28th 07 01:57 AM
Found Cell Highlighting after Search ULNazarene Excel Discussion (Misc queries) 1 August 21st 07 07:31 PM
Return text found in a search Dave R. Excel Worksheet Functions 4 May 12th 05 08:53 PM
The search key was not found error Nydia New Users to Excel 0 April 27th 05 03:09 PM


All times are GMT +1. The time now is 04:11 PM.

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

About Us

"It's about Microsoft Excel"