I am getting a range of object worksheet failed error on the line denoted with ***. I cant figure it out because if I step through the code after I get the error message, it doesn't error out again. Does anything look wrong?
Sub BuildMonthCalender()
Dim wkb As Workbook, shift_lines As Worksheet, month_lines As Worksheet, inputs As Worksheet, schedule As Worksheet
Dim d As Integer, w As Integer, last_row As Double, shift_line As Double, shifts As Double, p As Double, cRow As Double, cCol As Double
Dim counter As Double, cell_value As String
Set wkb = Excel.Workbooks("Call Center Headcount Model.xlsm")
Set schedule = wkb.Worksheets("Schedule")
Set shift_lines = ThisWorkbook.Worksheets("Shift Lines")
Set month_lines = ThisWorkbook.Worksheets("Month Lines")
Set inputs = wkb.Worksheets("Inputs")
schedule.Range("A1:K100000").Clear
last_row = month_lines.Range("A" & Rows.Count).End(xlUp).Row
shift_line = 3
shifts = 3
cRow = 0
cCol = 2
p = 1
'For shift_line = 3 To last_row
With month_lines
Do
If month_lines.Cells(shift_line, 1).Value <> "" Then
For shifts = shift_line To month_lines.Cells(shift_line, 1).CurrentRegion.Rows.Count + shift_line
cell_value = month_lines.Cells(shifts, 1).Value
If cell_value = "" Then
Exit For
End If
schedule.Cells(cRow + month_lines.Cells(shifts, 9).Value, cCol + month_lines.Cells(shifts, 8).Value) = month_lines.Cells(shifts, 7).Value
*****schedule.Range(Cells(p, 1), Cells(p + 5, 1)) = month_lines.Cells(shifts, 3).Value**
schedule.Range(Cells(p, 2), Cells(p + 5, 2)) = month_lines.Cells(shifts, 10).Value
Next shifts
cRow = cRow + 10
p = p + 10
End If
shift_line = .Cells(shift_line, 1).End(xlDown).Row + 3
Loop Until shift_line > last_row
End With
p = 0
For p = 1 To last_row
With schedule.Range(Cells(p, 3), Cells(p + 5, 9))
.Borders.LineStyle = xlContinuous
.HorizontalAlignment = xlCenter
End With
p = p + 9
Next p
MsgBox "Complete!"
End Sub