For some reason my code is exiting early, and I really have no idea why. I'm triggering the PasteRangeMacro sub via the PasteDay1 sub (among others) and it's really annoying that the macro isn't finishing, among other reasons because the code doesn't re-enable events and reset the calculation status.
It gives the "test0" debug print, and triggers the StartCell.Resize(DayRows,7).Value line, but does not trigger any of the following lines. I use Range.Value in other macros without this problem, so I'm stuck. Any ideas? Thank you so much.
I'm using the latest version of Excel with a file format of .xlsm on a Windows 10 computer.
Sub PasteRangeMacro(StartCell As Range)
Application.EnableEvents = False
If StoredCopyCell Is Nothing Then GoTo ErrorMessage
OldCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
Dim CopyStart As Range
Set CopyStart = StoredCopyCell
Debug.Print "test0"
StartCell.Resize(DayRows, 7).Value = CopyStart.Resize(DayRows, 7).Value
Debug.Print StartCell.Offset(0, 9).Resize(DayRows, 1).Address
StartCell.Offset(0, 9).Resize(DayRows, 1).Value = CopyStart.Offset(0, 9).Resize(DayRows, 1).Value
StartCell.Offset(0, 12).Resize(DayRows, 1).Value = CopyStart.Offset(0, 12).Resize(DayRows, 1).Value
StartCell.Offset(0, 15).Resize(DayRows, 1).Value = CopyStart.Offset(0, 15).Resize(DayRows, 1).Value
Debug.Print "test"
Application.EnableEvents = True
Application.Calculation = OldCalculationMode
ActiveSheet.Calculate
Exit Sub
ErrorMessage:
Application.EnableEvents = True
MsgBox "Error - Please use a Copy button before pressing a Paste button."
End Sub
Sub PasteDay1()
Dim StartCell As Range
Set StartCell = Range("E5")
Call PasteRangeMacro(StartCell)
End Sub
Bookmarks