Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Trap a find error

I have the following code. How can I most efficiently exit the function if no
target string is found?

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
strLastDeleteRow = rngFind.Row

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Trap a find error

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
If rngFind Is Nothing Then
MsgBox "Not Found"
Else
strLastDeleteRow = rngFind.Row
End If

HTH
"quartz" wrote:

I have the following code. How can I most efficiently exit the function if no
target string is found?

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
strLastDeleteRow = rngFind.Row

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Trap a find error

Thanks Jim, works great!

"Jim Thomlinson" wrote:

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
If rngFind Is Nothing Then
MsgBox "Not Found"
Else
strLastDeleteRow = rngFind.Row
End If

HTH
"quartz" wrote:

I have the following code. How can I most efficiently exit the function if no
target string is found?

strSearchColumn = "I:I"
strTarget = "0"
Set rngFind = Range(strSearchColumn).Find(strTarget,
SearchDirection:=xlPrevious)
strLastDeleteRow = rngFind.Row

Thanks in advance.

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
How to error trap "... cannot find the data..." message? [email protected] Excel Discussion (Misc queries) 4 August 29th 08 02:57 AM
Error Trap Not Working Otto Moehrbach[_6_] Excel Programming 7 April 13th 04 12:15 PM
Trap a DateValue Error Otto Moehrbach[_6_] Excel Programming 2 February 12th 04 04:51 PM
error trap Rhonda[_3_] Excel Programming 2 October 22nd 03 07:07 PM


All times are GMT +1. The time now is 08:52 PM.

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"