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.
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