#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Error Handler

Hi all,

i am using error handler in VBA code. Let me first explain u the
situation.

i have to find out a no. from one work book in another work book.
though i have used Vlookup to do this but i wanna do this in other
way. i will copy that no from that work book and will search that in
other work book and will do this task for n no of times using loop.
till the time i find the no its fine but if the no. um searching is
not present in the other sheet macro will give an error (error -91)..
so to avoid this i used Error handler. like ..

for i = 1 to n
On Error goto err1:

code.........

...


err1:

next i

but the problem with this code is, the error handler will not work if
the same situation appears again..

so please help me ho shud i do this

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Error Handler

This kind of code does not require an error handler. You are better off to
avoid the error in the first place. Post your code and we can take a look at
it.

To let you know what is going on once you encounter an error then your code
will be executing in error handling mode. You must clear that error using a
resume statement or a err.clear before you encounter another error otherwise
the new error will be unhandled (vba is still dealing with the first error).
--
HTH...

Jim Thomlinson


"sharad" wrote:

Hi all,

i am using error handler in VBA code. Let me first explain u the
situation.

i have to find out a no. from one work book in another work book.
though i have used Vlookup to do this but i wanna do this in other
way. i will copy that no from that work book and will search that in
other work book and will do this task for n no of times using loop.
till the time i find the no its fine but if the no. um searching is
not present in the other sheet macro will give an error (error -91)..
so to avoid this i used Error handler. like ..

for i = 1 to n
On Error goto err1:

code.........

...


err1:

next i

but the problem with this code is, the error handler will not work if
the same situation appears again..

so please help me ho shud i do this


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
What code do I use to attach event handler that will open my user. TeresaManley Excel Worksheet Functions 2 May 5th 07 09:55 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
merge handler error with Briefcase JH Excel Discussion (Misc queries) 0 September 6th 05 02:52 AM
Error Handler Not Working Bill Excel Discussion (Misc queries) 0 August 25th 05 07:13 PM


All times are GMT +1. The time now is 05:24 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"