+ Reply to Thread
Results 1 to 6 of 6

Can't enter break mode only sometimes

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Can't enter break mode only sometimes

    The following code resides in SubB which is called from SubA

    When SubA is initiated due to CLICKING a button (forms control on worksheet) it runs smoothly.

    When SubA is CALLED from a third Sub (SubX) it fails when trying to change the CodeName

    It fails whether stepping through or running automatic. (Of course it ends all code, SubA 7 Sub X, not just SubB.)

    Error:
    Can’t enter into break mode at this time

    Please Login or Register  to view this content.
    The reason I’m changing the codename is because regardless of what the user may do, I want to insure that this newly created CostDate sheet is ALWAYS DELTED prior to the creation of another.
    It could be weeks later when the code is run and Sheet1 is copied again to make a new CostDate sheet

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't enter break mode only sometimes

    Quote Originally Posted by carsto View Post

    The reason I’m changing the codename is because regardless of what the user may do, I want to insure that this newly created CostDate sheet is ALWAYS DELTED prior to the creation of another.
    I don't know why it errors.

    Instead of changing the code name, couldn't you just loop through the sheets and delete them by name.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Can't enter break mode only sometimes

    Not if the user changed the sheet name

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't enter break mode only sometimes

    With your original solution, the user could just copy the sheet manually.

    This would delete all other sheets by code name except code names Sheet1 and Sheet2

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Can't enter break mode only sometimes

    Yes the user can copy the sheet should they choose to. And there are times when they may want to retain historical data. They know they must rename it as they are aware the next run will delete the automatically created sheet.
    There are too many varying sheets in this workbook, used by different departments, to safely loop through and delete any not on a specific list.
    I appreciate the alternative suggestions but I’m only looking for insight on why code will function flawlessly every time when called from a sub that was initiated by a button yet fails every time when called from a different sub. All 3 subs are in different modules in the same workbook. Accessing the VBProject is always a little tricky.

  6. #6
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Can't enter break mode only sometimes

    Found this here:
    http://stackoverflow.com/questions/4...t-out-of-range

    Added these 3 lines after creating new sheet and before changing codename.
    Perhaps I could have used one or the other but I'm moving on.

    DoEvents
    Dim editor As Object
    Set editor = ThisWorkbook.VBProject.VBE.MainWindow

+ 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. [SOLVED] Install VBA Reference Library causes Can't enter break mode
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2015, 01:18 AM
  2. [SOLVED] "Can't enter break mode at this time" (Issues with adding controls at runtime)
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-16-2013, 07:10 PM
  3. "Can't enter break mode at this time" error
    By jp001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-11-2009, 09:19 AM
  4. [SOLVED] "Can't enter break mode at this time"
    By Paul T. in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2006, 07:00 PM
  5. Can't enter break mode at this time
    By CWillis in forum Excel General
    Replies: 2
    Last Post: 06-01-2006, 02:45 PM
  6. [SOLVED] Can't enter break mode
    By eugene in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-11-2006, 04:25 PM
  7. received message: Can't enter break mode at this time
    By William Weder in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2006, 10:00 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