cannot execute code in break mode?

RPM7

Board Regular
Joined
Nov 28, 2007
Messages
191
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?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
 
Upvote 0
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?
 
Upvote 0
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:
<script> function go(url) { window.open(url, "_self"); } function OpenInNewWindow(url) { go(url); } </script><script language="JavaScript" type="text/JavaScript"> <!-- function InlineDefNotFound() { alert(L_UNDEFINED_TEXT); } function AppendPopup(oSource, sPopup) { InitializeGlobalData(); if (typeof(allDivsInPage) == 'undefined' || null == allDivsInPage) return; var theDiv = allDivsInPage['divInlineDef_' + sPopup]; if (typeof(theDiv) == 'undefined' || null == theDiv) { InlineDefNotFound(); return; } if (theDiv.style.display.toUpperCase() != 'INLINE') theDiv.style.display = 'inline'; else theDiv.style.display = 'none'; } //--></script>
<P>You enter <A href="HV01200929.htm">break mode</A> when you suspend execution of code. This error has the following causes and solutions:</P> <P> <UL type=disc> <LI>You tried to run code from the <B class=bterm>Macro</B> dialog box. However, Visual Basic was already running code, although the code was suspended in break mode. <P>You may have entered break mode without knowing it, for example, if a <A href="HV01200929.htm">syntax error</A> or <A href="HV01200929.htm">run-time error</A> occurred. Continue running the suspended code, or terminate its execution before you run code from the <B class=bterm>Macro</B> dialog box. You can fix the error and choose <B class=bterm>Continue</B>, or you can return to the <B class=bterm>Macro</B> dialog box and restart the macro.</P></LI></UL><script> function go(url) { window.open(url, "_self"); } function OpenInNewWindow(url) { go(url); } </script><script language="JavaScript" type="text/JavaScript"> <!-- function InlineDefNotFound() { alert(L_UNDEFINED_TEXT); } function AppendPopup(oSource, sPopup) { InitializeGlobalData(); if (typeof(allDivsInPage) == 'undefined' || null == allDivsInPage) return; var theDiv = allDivsInPage['divInlineDef_' + sPopup]; if (typeof(theDiv) == 'undefined' || null == theDiv) { InlineDefNotFound(); return; } if (theDiv.style.display.toUpperCase() != 'INLINE') theDiv.style.display = 'inline'; else theDiv.style.display = 'none'; } //--> </script>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.
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top