On Error End Sub
Contents |
Forums Excel Questions Exit Sub On Error Results 1 to 8 of 8 Exit Sub On ErrorThis is a discussion on Exit Sub On Error within the Excel Questions forums, part of the Question Forums category; Hello All, Can one of you
On Error Vba
vba experts tell me what the code is that will automatically stop my macro ... vba on error exit function LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable on error goto line Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Aug 16th, 2003,06:59 PM #1 Yevette Board Regular Join Date Mar 2003 Location Los Angeles, CA Posts 328 Exit Sub On Error Hello All, Can one of
Vba Error Handling Best Practices
you vba experts tell me what the code is that will automatically stop my macro if a run-time error occurs? Or perhaps you could tell me how to "better write" the following macro so I don't get an error at all. I have a list of cells with numbers and what the macro does is insert "x" number of rows based on whatever the number is in the row (above) the active cell. For example: A1 = 8
On Error Goto 0
A2 = 2 A3 = 5 A4 = 3 below A4 3 rows are inserted, below A3 5 rows are inserted, etc. The macro works from the bottom up but errors out when it gets to the top (A1): Sub FormatForm() Range("A1").End(xlDown).Offset(1, 0).Activate Do Until ActiveCell = "A1" ActiveCell.Offset(-1, 0).Activate Dim i As Integer For i = 1 To ActiveCell.Offset(-1, 0).Value ActiveCell.EntireRow.Insert Next Loop End Sub I'm sure it has something to do with my Do Until or maybe I need an Error On statement, but not quite sure. Help would be appreciated! Thanks a lot! :o Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Aug 16th, 2003,07:51 PM #2 bat17 Board Regular Join Date Aug 2003 Location Maidstone, Kent UK Posts 1,470 This is not a good answer but it is getting late here Sub FormatForm() On Error GoTo GetOut Range("A1").End(xlDown).Offset(1, 0).Activate Do Until ActiveCell = "A1" ActiveCell.Offset(-1, 0).Activate Dim i As Integer For i = 1 To ActiveCell.Offset(-1, 0).Value ActiveCell.EntireRow.Insert Next Loop GetOut: End Sub Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Aug 16th, 2003,07:55 PM #3 Tom Urtis MrExcel MVP Join Date Feb 2002 Location San Francisco, California USA Posts 11,069 Re: Exit Sub On Error One way, inserting rows above: Sub Test1() 'Insert up On Error GoTo EH Dim x As Long, y As Long Application.ScreenUpdating =
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn vba on error goto 0 more about Stack Overflow the company Business Learn more about hiring developers or posting
Vba Exit Sub
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community try catch vba Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Excel VBA - Is it possible to call sub on http://www.mrexcel.com/forum/excel-questions/58276-exit-sub-error.html error? up vote 0 down vote favorite I've been searching, but I can't really find something that answers this question. I'm getting an error and I know whats causing it and it not really a problem. It just needs to run another sub before running the next line of code if this error occurs. So that made me wonder: Is it possible to do something like this: On Error http://stackoverflow.com/questions/26427715/excel-vba-is-it-possible-to-call-sub-on-error Call Sheet1.TestSub Thanks in advance! excel vba excel-vba error-handling share|improve this question asked Oct 17 '14 at 14:53 Goos van den Bekerom 1,0471725 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted No. The best you can do is to branch to a separate section of code to handle the error and then branch back to the line immediately below the line raising the error. (if you know what that line is!) share|improve this answer answered Oct 17 '14 at 14:58 Gary's Student 47.1k61334 I know the line, so if I make an error handler, call the sub in there and then branch back( GoTo 0 ) is the best way to do this? –Goos van den Bekerom Oct 17 '14 at 15:00 or what is the code to branch back to that line? –Goos van den Bekerom Oct 17 '14 at 15:00 That is the only easy way....you need a label on the line below the "raiser". Then *GOTO that label. –Gary's Student Oct 17 '14 at 15:02 Ah I see, thank you very much! will accept answer as soon as 10 minutes are over ;) –Goos v
your question and get tips & solutions from a community of 418,614 IT Pros & Developers. It's quick & easy. How to Exit Sub on Error? P: n/a deko Is there a shorthand way to Exit https://bytes.com/topic/access/answers/193185-how-exit-sub-error Sub On Error? This does not seem to work: On Error Exit Sub And I don't want to use: On Error GoTo 0 Must I use: GoTo Exit_Here? Nov 12 '05 #1 Post Reply Share this Question 4 Replies P: n/a Steve Jorgensen On Fri, 16 Jan 2004 00:34:25 GMT, "deko"