ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Trapping (https://www.excelbanter.com/excel-programming/326809-error-trapping.html)

Andrew

Error Trapping
 
I'm looping through a list searching for a word that may or may not be in the
list. I use 'on error goto' to take action if a word can't be found in the
list and then want to continue searching for the next word(s). I get an
error (not sure of exact wording) and can't continue - any ideas.

It seems it is not just a result of searching, I'm pretty sure it's whenever
you try to continue running code after a error has been trapped.

It is not as easy as using the return keyword.

Thanks in advance.

--
Andrew

Patrick Molloy[_2_]

Error Trapping
 
what is your list? is it a table in a spreadsheet?
if it IS then you can use the FIND method of a range

dim source as range ' table of data
dim found as range ' found cell from find
dim what as string ' text to search for
dim firstadd as striing ' address of the first found cell

what = "something"

set source = worksheets("main").Range("mydata")
set found = source.find(what)
if not found is nothing then
firstadd = found.address
Do
' process found
set found = source.find(found)
Loop until found.address = firstadd
end if

this is a pretty standard loop --- much like the one in Help.

If you are not searching for your text this way, then please explain more
clearly.



"Andrew" wrote:

I'm looping through a list searching for a word that may or may not be in the
list. I use 'on error goto' to take action if a word can't be found in the
list and then want to continue searching for the next word(s). I get an
error (not sure of exact wording) and can't continue - any ideas.

It seems it is not just a result of searching, I'm pretty sure it's whenever
you try to continue running code after a error has been trapped.

It is not as easy as using the return keyword.

Thanks in advance.

--
Andrew



All times are GMT +1. The time now is 10:44 PM.

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