"Can't execute code in break mode" when copying worksheet array to a new file

thom612

New Member
Joined
Sep 16, 2019
Messages
1
I am trying to execute the code below to create a set of workbooks to send out various people in my organization. It copies a series of worksheets to a new file, breaks the links, and saves with their name and position number.

When I step through this code manually, it works as intended. However, after I execute the line marked in red below (the Sheets.....copy) I get three successive "Can't execute code in break mode" errors, after which it properly executes.

However, if I try to run the code normally it crashes Excel.

Any thoughts about what I'm doing wrong here? If I have to I will just manually step through it I suppose.

Code:
Sub create_files_3()
Dim Name
Dim Position
For i = 2 To 65
    Position = Sheets("pos_run").Cells(i, 1).Value
    Name = Sheets("pos_run").Cells(i, 2).Value
    Sheets("Control").Cells(7, 4) = Position
[COLOR=#ff0000]    Sheets(Array("Summary", "Sep_1-14", "Sep_15-28", "Sep_29-Oct_12", "Oct_13-26", _[/COLOR]
[COLOR=#ff0000]        "Oct_27-Nov_9", "Nov_10-23", "Nov_24-Dec_7", "Dec_8-21", "Dec_22-Jan_4", "Jan_5-18", _[/COLOR]
[COLOR=#ff0000]        "Jan_19-Feb_1", "Feb_2-15", "Feb_16-29", "Mar_1-14", "Mar_15-28", "Mar_29-Apr_11", _[/COLOR]
[COLOR=#ff0000]        "Apr_12-25", "Apr_26-May_9", "May_10-23", "May_24-Jun_6", "Jun_7-Jun_20", _[/COLOR]
[COLOR=#ff0000]        "Jun_21-Jul_4")).Copy[/COLOR]
    ActiveWorkbook.BreakLink Name:= _
        "C:\Users\throe001\Desktop\Time and Effort Sheets\Time & Effort Template 2020.xlsm" _
        , Type:=xlExcelLinks
    ActiveWindow.SelectedSheets.Visible = False
    ChDir "C:\Users\throe001\Desktop\Time and Effort Sheets\Worksheets"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Users\throe001\Desktop\Time and Effort Sheets\Worksheets\" & Name & "-" & Position & ".xlsx" _
        , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
Next i
End Sub
 

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

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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