Page 1 of 2 12 LastLast
Results 1 to 10 of 12

cannot execute code in break mode?

This is a discussion on cannot execute code in break mode? within the Excel Questions forums, part of the Question Forums category; I'm a a complete novice with VBA . I have set up a sheet with macro buttons that hide/unhide rows ...

  1. #1
    Board Regular
    Join Date
    Nov 2007
    Posts
    131

    Default cannot execute code in break mode?

    I'm a a complete novice with VBA. I have set up a sheet with macro buttons that hide/unhide rows to give a different display on screen. I have also set up a reset button which i have set to return all cells to a default status and hide all the rows except those of the first display. Everything seems to work ok except the reset button.
    I get the message "cannot execute code in break mode". Can anyone help?

  2. #2
    MrExcel MVP Cindy Ellis's Avatar
    Join Date
    Jun 2006
    Location
    California
    Posts
    1,611

    Default Re: cannot execute code in break mode?

    Did you set a break in one of the macros for troubleshooting/debugging? If so, get rid of the break.
    If not, please post your code using the "code" tags (the "#" icon in the reply panel). It's too hard to guess what might be wrong or how to fix it without seeing what's already there.
    Cindy
    Cindy

    Excel 2007 on XP at work, 2003 on Vista at home.
    If you need to post part of your worksheet, try one of these: Excel jeanie, MrExcel HTML Maker or
    Borders-Copy-Paste

  3. #3
    Board Regular
    Join Date
    Nov 2007
    Posts
    131

    Default Re: cannot execute code in break mode?

    Hi Cindy, Thanks for the prompt reply.
    I don't know anything about VBA really. The macos I've made are pretty much mouse clicks and deleting certain cells etc..
    I couldn't find the (# icon in the reply panel).
    The code is:

    Sub Reset_All()
    '
    ' Reset_All Macro
    ' Macro recorded 17/05/2008 by Ruairi
    '

    '
    Range("K177:L177").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("N177:O177").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("K138:L138").Select
    ActiveCell.FormulaR1C1 = "Unknown"
    Range("H105:I105").Select
    ActiveCell.FormulaR1C1 = "Unguided"
    Range("H106:I106").Select
    ActiveCell.FormulaR1C1 = "C4000"
    With ActiveCell.Characters(Start:=1, Length:=5).Font
    .Name = "Arial"
    .FontStyle = "Regular"
    .Size = 10
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("H107:I107").Select
    ActiveCell.FormulaR1C1 = "6000"
    Range("K105:L105").Select
    ActiveCell.FormulaR1C1 = "Regular Counterbalance"
    With ActiveCell.Characters(Start:=1, Length:=22).Font
    .Name = "Arial"
    .FontStyle = "Regular"
    .Size = 9.5
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With
    Range("K107:L107").Select
    ActiveCell.FormulaR1C1 = "6000"
    Range("K108").Select
    ActiveWindow.SmallScroll Down:=-42
    Range("H69:I69").Select
    ActiveCell.FormulaR1C1 = "6000"
    Range("H70:I70").Select
    ActiveCell.FormulaR1C1 = "1200"
    Range("H71:I71").Select
    ActiveCell.FormulaR1C1 = "600"
    Range("H72").Select
    ActiveWindow.SmallScroll Down:=-28
    Range("H39:I39").Select
    ActiveCell.FormulaR1C1 = "100"
    Range("H40:I40").Select
    ActiveCell.FormulaR1C1 = "50"
    Range("H42:I42").Select
    ActiveCell.FormulaR1C1 = "1"
    Range("H43").Select
    ActiveWindow.SmallScroll Down:=147
    Rows("64:194").Select
    Range("C194").Activate
    Selection.EntireRow.Hidden = True
    ActiveWindow.SmallScroll Down:=-21
    Rows("38:63").Select
    Range("C63").Activate
    Selection.EntireRow.Hidden = False
    Range("C1:V63").Select
    Range("C63").Activate
    ActiveWindow.Zoom = True
    Range("H39:I39").Select
    End Sub


    There's probably alot of nonsense in there. I tried to do it in as little steps as possible, but since I can't read code, I don't know what all's needed in the above.
    Have you any ideas o what's wrong?

  4. #4
    Board Regular
    Join Date
    May 2008
    Location
    Netherlands
    Posts
    692

    Default Re: cannot execute code in break mode?

    You're VBA window is probably still open in debug mode, so close that down. That should solve your problem. Make sure to checkout the in-program help too:
    ********> function go(url) { ************(url, "_self"); } function OpenInNewWindow(url) { go(url); } *********>******** language="JavaScript" type="text/JavaScript"> *********>

    You enter break mode when you suspend execution of code. This error has the following causes and solutions:

    • You tried to run code from the Macro dialog box. However, Visual Basic was already running code, although the code was suspended in break mode.

      You may have entered break mode without knowing it, for example, if a syntax error or run-time error occurred. Continue running the suspended code, or terminate its execution before you run code from the Macro dialog box. You can fix the error and choose Continue, or you can return to the Macro dialog box and restart the macro.

    ********> function go(url) { ************(url, "_self"); } function OpenInNewWindow(url) { go(url); } *********>******** language="JavaScript" type="text/JavaScript"> *********>break mode

    Temporary suspension of program execution in the development environment. In break mode, you can examine, debug, reset, step through, or continue program execution. You enter break mode when you:
    • Encounter a breakpoint during program execution.
    • Press CTRL+BREAK during program execution.
    • Encounter a Stop statement or untrapped run-time error during program execution.
    • Add a Break When True watch expression. Execution stops when the value of the watch changes and evaluates to True.
    • Add a Break When Changed watch expression. Execution stops when the value of the watch changes.
    Regards,
    Stefan


    Using Office 2010

  5. #5
    Board Regular
    Join Date
    Nov 2007
    Posts
    131

    Default Re: cannot execute code in break mode?

    Thanks dafan, I'm sorry for being a pest.
    I literally know nothing about VBA. Literally...
    I don't understand what a break code or debug mode is.
    The help button told me to Trust access to Visual Basic Project in the macro security. It didn't help.
    I deleted the code regarding the spec of the font which then skipped the problem down to "Selection.EntireRow.Hidden = True" .
    The main purpose of the macro is to hide and unhide rows in the sheet.
    Is there a straight forward way to fix this that even I could do?

  6. #6
    MrExcel MVP Cindy Ellis's Avatar
    Join Date
    Jun 2006
    Location
    California
    Posts
    1,611

    Default Re: cannot execute code in break mode?

    I've copied your macro into a workbook and it runs without error (although it could be simplified quite a bit).
    Are you really only trying to hide and unhide rows? The reset macro is setting values in several cells. Is that intended?
    Cindy
    Cindy

    Excel 2007 on XP at work, 2003 on Vista at home.
    If you need to post part of your worksheet, try one of these: Excel jeanie, MrExcel HTML Maker or
    Borders-Copy-Paste

  7. #7
    Board Regular
    Join Date
    Nov 2007
    Posts
    131

    Default Re: cannot execute code in break mode?

    Yea, I put in values in certain cells to have them in a default state. I deleted the code regarding the font description but it didn't help, the error shifted to
    "Selection.EntireRow.Hidden = True"
    I'm currently running this on Excel 2003 on my home PC, but originally started it on 2007 at work. Would that have any bearing on it?

  8. #8
    MrExcel MVP Cindy Ellis's Avatar
    Join Date
    Jun 2006
    Location
    California
    Posts
    1,611

    Default Re: cannot execute code in break mode?

    I'm not yet familiar with Excel 2007...we'll be upgrading at work in about 4 months. So, it's possible that there's something in the workbook that is using resources or functions that are newly available in Excel 2007. But the code you posted works just fine in Excel 2000, so Excel 2003 shouldn't be the issue. If you save and re-open the workbook, and run the macro before doing anything else, does it still give the error? I'm wondering if one of your other macros is triggering the problem, so the system is being pushed into break mode, which won't then allow another macro to run.
    FYI...
    Here's a first pass at simplifying the code (not optimized, just simplified)...but I doubt it will solve the "break mode" problem, since the functionality is the same as the code you posted.
    Code:
    Sub Reset_All()
    '
    ' Reset_All Macro
    ' Macro recorded 17/05/2008 by Ruairi
    '
    '
        Range("H39").FormulaR1C1 = "100"
        Range("H40").FormulaR1C1 = "50"
        Range("H42").FormulaR1C1 = "1"
        Range("H69").FormulaR1C1 = "6000"
        Range("H70").FormulaR1C1 = "1200"
        Range("H71").FormulaR1C1 = "600"
        Range("H105").FormulaR1C1 = "Unguided"
        Range("H106").FormulaR1C1 = "C4000"
        Range("H107").FormulaR1C1 = "6000"
        Range("K105").FormulaR1C1 = "Regular Counterbalance"
        Range("K107").FormulaR1C1 = "6000"
        Range("K138").FormulaR1C1 = "Unknown"
        Range("K177").FormulaR1C1 = "0"
        Range("N177").FormulaR1C1 = "0"
        With Range("H106").Font
            .Name = "Arial"
            .FontStyle = "Regular"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
        End With
        With Range("K105").Font
            .Name = "Arial"
            .FontStyle = "Regular"
            .Size = 9.5
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
        End With
        Rows("64:194").EntireRow.Hidden = True
        Rows("38:63").EntireRow.Hidden = False
        Range("C1:V63").Select
        ActiveWindow.Zoom = True
        Range("C1").Select
    End Sub
    --Cindy
    Cindy

    Excel 2007 on XP at work, 2003 on Vista at home.
    If you need to post part of your worksheet, try one of these: Excel jeanie, MrExcel HTML Maker or
    Borders-Copy-Paste

  9. #9
    Board Regular
    Join Date
    Nov 2007
    Posts
    131

    Default Re: cannot execute code in break mode?

    Thanks Cindy,
    Unfortunately the problem persists. I tried deleting the font spec again and the problem shifted to the hidden rows.
    When I deleted the code for the hidden/unhidden rows, everything worked ok, except the spreadsheet doesn't reset the display and return to the starting point as i wanted it to.
    Its a bit frustrating. I've developed this calculator which will be given to our sales men and dealers, so I'll have to have it working on both 2007 & 2000 as not everyone will have the same setup.

  10. #10
    MrExcel MVP Cindy Ellis's Avatar
    Join Date
    Jun 2006
    Location
    California
    Posts
    1,611

    Default Re: cannot execute code in break mode?

    You mentioned in your original post that this is being run from a button on the form. Have you tried executing by selecting the macro from the macro dialog? (Tools, macro, macros, then select the macro and click Run).
    If that still gives the same error, try copying the code into a new empty workbook, into a module with nothing else in it. Close the original workbook so there are no possible conflicts. Do you still get the error? I haven't tried running it from a button, but I can run it multiple times without error from the macros menu.
    Cindy

    Excel 2007 on XP at work, 2003 on Vista at home.
    If you need to post part of your worksheet, try one of these: Excel jeanie, MrExcel HTML Maker or
    Borders-Copy-Paste

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com