Error - Can't execute code in break mode

mazza

New Member
Joined
Jun 26, 2007
Messages
6
hi,

I'm at my new work and i've got a small job from my boss, he wants me to correct a function in a excel macro. I'm quite new to vba programming so its a hard task for me. When i klick on the button to activate the macro i get the error Can't execute code in break mode. As far as i've understood this is because there is something else going on at the same time.
This is the begning of the function, it continues futher down but the debug says the problem is here(the bold underlined sentance). Is the problem here or is it somewhere else in the gaint excel document, its very big.:

Function IndividX()

Dim JobLd(256)

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Sheets("ResourcePlanW").Range("A7:IV6000").ClearContents
EndRowP = Sheets("ResourcePlan").Columns("A").Find("EndRow").Row - 1

FirstRowP = 8
FirstClmnRP = Sheets("ResourcePlanX").Rows(4).Find("Datum").Column + 2

Sheets("ResourcePlanW").Range("A8:IV6000").Select
With Selection.Font
'.Name = "Arial"
.FontStyle = "Normal"
'.Size = 10
'.Strikethrough = False
'.Superscript = False
'.Subscript = False
'.OutlineFont = False
'.Shadow = False
'.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
NxtClmn = 7
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi - Welcome to the board :)

Does this happen as soon as you open the workbook?

IE: Open Workbook >> Click Button >> Error Message?

Or is it possible you have been debugging it and tried to run it again?

If the latter is the case you need to stop the code by pressing the Stop button at the top of the VBE (Play / Pause / Stop).

Other than that, I've never seen that before .. :-?
 
Upvote 0
Welcome to the board.

1. Can't execute code in break mode means that some code previously errored, and you clicked Debug. VBA is now in a Paused Mode. It can't start a new code until you either resolve the error and resume the previous code, or STOP the previous code that errored. In the VBA window, you should see a Stop and a Play button (like those of a CD Player) on the toolbar. Press Play to try to Resume the code that priviously failed, or press Stop to END the previous code that failed.

2. As for the problem, If that's the line highlighted, my first guess would be that the Sheet ResourcePlanW either does not exist, or is hidden. If it doesn't exist, well, you need to make it exist, or change the sheetname the code is trying to select. If it's just hidden, you can either manually unhide it, or put this line before the highlighted line.

Sheets("ResourcePlanW").Visible = True
 
Upvote 0
Actually, I can guess the sheet does exist and is just hidden. Because previous lines referred to the sheet without selecting it. So it must exist.

You can change that code to NOT select the sheet, the same way the previous code did.

Try replacing the code with this..

Code:
Function IndividX() 

Dim JobLd(256) 

With Application 
.Calculation = xlManual 
.MaxChange = 0.001 
End With 
ActiveWorkbook.PrecisionAsDisplayed = False 

Sheets("ResourcePlanW").Range("A7:IV6000").ClearContents 
EndRowP = Sheets("ResourcePlan").Columns("A").Find("EndRow").Row - 1 

FirstRowP = 8 
FirstClmnRP = Sheets("ResourcePlanX").Rows(4).Find("Datum").Column + 2 

With Sheets("ResourcePlanW").Range("A8:IV6000").Font 
'.Name = "Arial" 
.FontStyle = "Normal" 
'.Size = 10 
'.Strikethrough = False 
'.Superscript = False 
'.Subscript = False 
'.OutlineFont = False 
'.Shadow = False 
'.Underline = xlUnderlineStyleNone 
.ColorIndex = xlAutomatic 
End With 
Sheets("ResourcePlanW").Range("A8:IV6000").Interior.ColorIndex = xlNone 
NxtClmn = 7
 
Upvote 0
Thanks for the help guys, a friend of mine simced to know the problem aswell, i had to stop and then when i started the macro it worked fine.
Anyway i'll be asking more questions later as they pop up, now i'll return to studdy some more vba, cya later
 
Upvote 0

Forum statistics

Threads
1,223,564
Messages
6,173,060
Members
452,501
Latest member
FrankSit

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