+ Reply to Thread
Results 1 to 6 of 6

Exit Private Subroutine

  1. #1
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Exit Private Subroutine

    Hello, could some one please help me with the following:

    When I run the Sub Data_to_Text() macro (in Module 1) and the following part of the macro is being executed:

    Please Login or Register  to view this content.

    Excel 2003 also runs Private Sub Worksheet_Change(ByVal Target As Range) subroutine located in the Sheet 1 (Data) Microsoft Excel Object for each cell that the user has selected in the Worksheet named "Data".

    Is there a way to exit the private subroutine instead of running through most of the code?

    I have attached a copy of the spreasheet with "dummy-data".

    Any help is greatly appreciated.

    Kind regards,

    Chris

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by longbow007; 02-25-2010 at 01:24 AM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Exit Private Subroutine

    Put
    Please Login or Register  to view this content.
    At the point you want to exit
    eg
    Please Login or Register  to view this content.
    This will stop if x=y and run on if not

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Exit Private Subroutine

    Another possibility

    To prevent a macro triggering a change event

    Please Login or Register  to view this content.
    This will allow a macro to change a cell and bypass Private Sub Worksheet_Change

  4. #4
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Exit Private Subroutine

    Quote Originally Posted by Marcol View Post
    Another possibility

    To prevent a macro triggering a change event

    Please Login or Register  to view this content.
    This will allow a macro to change a cell and bypass Private Sub Worksheet_Change

    Hi Marcol, thanks for your help, but could you please advise what

    Please Login or Register  to view this content.

    code I need to prevent a macro triggering a change event besides:

    Please Login or Register  to view this content.
    Cheers,

    Chris

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Exit Private Subroutine

    Hi Longbow007

    ' some code
    Whatever code you need!

    for example if this is your Sub

    This will trigger Private Sub Worksheet_Change
    Please Login or Register  to view this content.
    This will not
    Please Login or Register  to view this content.
    Always remember to reset Application.EnableEvents =True
    Otherwise Events will not happen until you do.

  6. #6
    Forum Contributor
    Join Date
    06-13-2009
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    245

    Re: Exit Private Subroutine

    Thanks again Marcol - very much appreciated.

    Kind regards,

    Chris.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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