For some reason, VBA isn't even letting me step through the code with F8 ever since I added this portion of code to my program. When I try to run it, the spreadsheet highlights a cell as if it's about to copy it (dashed border) and the run-time error pops up. This is driving me nuts! Any suggestions on debugging?
Code:
lastcombinedrow = Range("F" & Rows.Count).End(xlUp).Row
counter = 0
For Each cell In Range("F4", Range("F" & Rows.Count).End(xlUp))
n = Len(Trim(cell))
If InStr(cell.Text, "x") > 0 Then
If n = 6 Then
counter = counter + 1
If counter = 1 Then
firstx = cell.Row
End If
Range(cell.Offset(0, -1), cell).Select
Selection.Cut
Range(cell.Offset(0, 2)).Select
ActiveSheet.Paste
End If
If n = 7 Then
counter = counter + 1
If counter = 1 Then
firstx = cell.Row
End If
Range(cell.Offset(0, -1), cell).Select
Selection.Cut
Range(cell.Offset(0, 2)).Select
ActiveSheet.Paste
End If
End If
Next
'Copy the 12:00 x - 12:59 x times over first
For Each cell In Range("E" & firstx, Range("E" & lastcombinedrow))
n = Len(Trim(cell.Offset(0, 3)))
If n = 7 Then
Range(cell.Offset(0, 2), cell.Offset(0, 3)).Select
Selection.Copy
Range("E" & firstx).Select
ActiveSheet.Paste
End If
Next
'Copy the remaining end-of-day times
For Each cell In Range(Range("E" & Rows.Count).End(xlUp).Offset(1), Range("E" & lastcombinedrow))
Range(cell.Offset(0, 2), cell.Offset(0, 3)).Select
Selection.Copy
Range("E" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Next