Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default on error goto

Hi all!

i have the following code:

<BEGIN VBA CODE
On Error GoTo errorhandler1
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), 1), 0)

errorhandler1:
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), -1) - 1, 0)
Resume Next
<END VBA CODE

if i am thinking correctly, this should execute the first set loc1 and if an
error is found, then go to errorhandler1 and execute that code, then continue
with the next line after resume next - correct?

and if no error found, then it should skip errorhandler1 altogether?

if this is true - why is it not skipping the errorhandler1?
(i have tried commenting out the
on error goto, errorhandler1, the second set loc1, and resume next
and no error is found.

am i not going about this correctly?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default on error goto

If the first is successful, the code then executes the code in the
errorhandler just as you reserved. The label errorhandler1 is nothing but
that, a label. It just marks a position in the code. You could have named
it
Gixxer_J_97:

and use
on Error goto Gixxer_J_97



It would be something like:

<BEGIN VBA CODE
On Error GoTo errorhandler1
Set loc1 = wamer.Offset(Application. _
WorksheetFunction.Match(addCodeBox, _
Range(wamer, find), 1), 0)
goto NextTest
errorhandler1:
Set loc1 =
wamer.Offset(Application. _
WorksheetFunction.Match( _
addCodeBox, Range(wamer, _
find), -1) - 1, 0)
Resume NextTest
NextTest:
<END VBA CODE
--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
Hi all!

i have the following code:

<BEGIN VBA CODE
On Error GoTo errorhandler1
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), 1), 0)

errorhandler1:
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), -1) - 1, 0)
Resume Next
<END VBA CODE

if i am thinking correctly, this should execute the first set loc1 and if

an
error is found, then go to errorhandler1 and execute that code, then

continue
with the next line after resume next - correct?

and if no error found, then it should skip errorhandler1 altogether?

if this is true - why is it not skipping the errorhandler1?
(i have tried commenting out the
on error goto, errorhandler1, the second set loc1, and resume next
and no error is found.

am i not going about this correctly?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default on error goto

thanks Tom -
i think i was thinking that it was more of a control structure like if / endif


"Tom Ogilvy" wrote:

If the first is successful, the code then executes the code in the
errorhandler just as you reserved. The label errorhandler1 is nothing but
that, a label. It just marks a position in the code. You could have named
it
Gixxer_J_97:

and use
on Error goto Gixxer_J_97



It would be something like:

<BEGIN VBA CODE
On Error GoTo errorhandler1
Set loc1 = wamer.Offset(Application. _
WorksheetFunction.Match(addCodeBox, _
Range(wamer, find), 1), 0)
goto NextTest
errorhandler1:
Set loc1 =
wamer.Offset(Application. _
WorksheetFunction.Match( _
addCodeBox, Range(wamer, _
find), -1) - 1, 0)
Resume NextTest
NextTest:
<END VBA CODE
--
Regards,
Tom Ogilvy




"Gixxer_J_97" wrote in message
...
Hi all!

i have the following code:

<BEGIN VBA CODE
On Error GoTo errorhandler1
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), 1), 0)

errorhandler1:
Set loc1 =
wamer.Offset(Application.WorksheetFunction.Match(a ddCodeBox, Range(wamer,
find), -1) - 1, 0)
Resume Next
<END VBA CODE

if i am thinking correctly, this should execute the first set loc1 and if

an
error is found, then go to errorhandler1 and execute that code, then

continue
with the next line after resume next - correct?

and if no error found, then it should skip errorhandler1 altogether?

if this is true - why is it not skipping the errorhandler1?
(i have tried commenting out the
on error goto, errorhandler1, the second set loc1, and resume next
and no error is found.

am i not going about this correctly?




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
On Error Goto ignored Fred Smith Excel Programming 4 January 8th 05 03:49 AM
On Error GoTo benb Excel Programming 3 January 5th 05 01:15 AM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM
On error goto 0 David Excel Programming 2 November 18th 03 01:43 PM


All times are GMT +1. The time now is 04:43 AM.

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"