code line number

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am writing a VBA a code in Excel (VB6 format). I need to
know is there any methods that I can store the" code line
number" in a variable. This will help me a lot for error
trapping.

I would appreciate your help.

Regards
Masoud
 
If you number you lines, you have the line number in erl

Sub Tester1()
On Error goto ErrHandler:
001 for i = 1 to 10
002 j = i ^ 2
003 next i
004 err.Raise 5001
005 for i = 1 to 10
006 k = i ^ 2
007 next i
008 exit sub
ErrHandler:
msgbox err.Number & " at line number " & erl
End Sub


for example.
 
Hi Tom,

Thanks for the answer. Is there any way that we can get the line number
without being obliged to add the line numbers. Our code is a legacy code with
more than 1 Million line of VBA code:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top