Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Moidule Line # continued

OK. Alex and Geof were very helpful - thanks. However, the next logical
step would then be able to 'GoTo' Erl. To simply code GoTo Erl produces an
missing label error.

This is not critical but, how then would one have a jump to that line after
anouncing it's presence? Again, just curious.

TIA
doco


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Moidule Line # continued

Don

something like:

Sub Test()
' code
GoTo ErrL
' code
MsgBox "don't get here"
' code
ErrL:
MsgBox "but do get here"
End Sub

Note the colon after the label


Regards

Trevor


"Don Cossitt" wrote in message
...
OK. Alex and Geof were very helpful - thanks. However, the next logical
step would then be able to 'GoTo' Erl. To simply code GoTo Erl produces
an missing label error.

This is not critical but, how then would one have a jump to that line
after anouncing it's presence? Again, just curious.

TIA
doco



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Moidule Line # continued

Yes I understand how to label a line. But if, in this case I desire to
'GoTo' a line number - not labeled.

Eg.

Public Sub TestError()
Dim lErr As Long
10 On Error GoTo EH

20 lErr = 1 / 0

30 On Error GoTo 0
40 Exit Sub

EH:

50 MsgBox "Error " & err.Number & vbCr & _
err.Description & " in line " & Erl, vbInformation,
"TestError"

GoTo Erl ' this part... how would one jump to the
offending line? Again, just curious - probably wouldn't do it actually.

End Sub


"Trevor Shuttleworth" wrote in message
...
Don

something like:

Sub Test()
' code
GoTo ErrL
' code
MsgBox "don't get here"
' code
ErrL:
MsgBox "but do get here"
End Sub

Note the colon after the label


Regards

Trevor


"Don Cossitt" wrote in message
...
OK. Alex and Geof were very helpful - thanks. However, the next logical
step would then be able to 'GoTo' Erl. To simply code GoTo Erl produces
an missing label error.

This is not critical but, how then would one have a jump to that line
after anouncing it's presence? Again, just curious.

TIA
doco





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Moidule Line # continued

Don,

Never use Goto in an error handling block of code. Instead, use
Resume to go to the line that cause the error, or Resume Next to
go to the line following the line that caused the error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Don Cossitt" wrote in message
...
Yes I understand how to label a line. But if, in this case I
desire to 'GoTo' a line number - not labeled.

Eg.

Public Sub TestError()
Dim lErr As Long
10 On Error GoTo EH

20 lErr = 1 / 0

30 On Error GoTo 0
40 Exit Sub

EH:

50 MsgBox "Error " & err.Number & vbCr & _
err.Description & " in line " & Erl,
vbInformation, "TestError"

GoTo Erl ' this part... how would one jump
to the offending line? Again, just curious - probably wouldn't
do it actually.

End Sub


"Trevor Shuttleworth" wrote in
message ...
Don

something like:

Sub Test()
' code
GoTo ErrL
' code
MsgBox "don't get here"
' code
ErrL:
MsgBox "but do get here"
End Sub

Note the colon after the label


Regards

Trevor


"Don Cossitt" wrote in message
...
OK. Alex and Geof were very helpful - thanks. However, the
next logical step would then be able to 'GoTo' Erl. To
simply code GoTo Erl produces an missing label error.

This is not critical but, how then would one have a jump to
that line after anouncing it's presence? Again, just
curious.

TIA
doco







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
Average With < Continued hamricka[_7_] Excel Worksheet Functions 4 August 20th 09 05:02 PM
Excel Function . . . Continued Charlie Excel Discussion (Misc queries) 3 June 23rd 09 05:41 PM
Median continued Bony Pony[_2_] Excel Discussion (Misc queries) 12 December 10th 08 06:53 AM
If then statement continued! Add to distribution list without opening Excel Discussion (Misc queries) 1 October 20th 06 11:02 PM
continued help needed scrabtree[_2_] Excel Programming 3 September 17th 04 07:49 PM


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