![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 12:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com