+ Reply to Thread
Results 1 to 4 of 4

Quitting a macro after error is detected?

  1. #1
    Registered User
    Join Date
    12-26-2016
    Location
    London, England
    MS-Off Ver
    365
    Posts
    79

    Quitting a macro after error is detected?

    Hi - I have the following VBA and need to add some code at the end of the line to Quit the Macro after “err.Clear” at present it proceeds to the next lines until the end.

    Can anyone help?


    Please Login or Register  to view this content.
    Ta

    Hans

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Quitting a macro after error is detected?

    Do you mean like

    Please Login or Register  to view this content.
    ?

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Quitting a macro after error is detected?

    Please Login or Register  to view this content.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  4. #4
    Registered User
    Join Date
    08-09-2015
    Location
    CzR
    MS-Off Ver
    MS Office 2013
    Posts
    41

    Re: Quitting a macro after error is detected?

    If you want to quit the subroutine after error, write the line like this:

    Please Login or Register  to view this content.
    or longer but possibly easier to read:

    Please Login or Register  to view this content.
    There's no need of Err.Clear; the Err object is cleared automatically when the subroutine terminates and that's what the 'Exit Sub' command does.
    Last edited by JBeaucaire; 03-01-2017 at 05:08 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Error cannot be detected?
    By LuisSuarez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2016, 10:58 AM
  2. Compile Error : Ambiguous name detected
    By vasanthrs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2013, 09:58 AM
  3. VBA Compile Error: Ambiguous name detected
    By kieranoduill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 05:31 PM
  4. [SOLVED] compile error ambiguous name detected!?
    By Margate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2013, 08:49 PM
  5. Ambiguous name detected error
    By jpxexcelforum in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-07-2011, 06:04 PM
  6. Macro quitting before completion
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-25-2008, 04:29 PM
  7. Compile error: Ambiguous name detected
    By Aletha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2008, 05:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1