I am using the code below to copy a formula down to the last row in the active sheet. Then copy paste the values.
When running the macro on a sheet where the active range is small I am not having any issues. However, when I run the macro on a sheet with 66 columns and 900,000 rows Excel crashes. This was working on the larger dataset until a few days ago and I did not change anything.
I tried disabling COM add-ins and running in safe mode, however, I am getting the same results. Runs fine on smaller sheets, crashes on larger sheets.
When I step through the macro, it crashes at the line in bold below. Is there a maximum ActiveSheet.Cells range size that is causing issues?
Thanks for taking a look!
Sub CopyPasteFormulas()
Dim MyRow
Dim MyCol
Dim lastRow As Long
Application.Calculation = xlManual
MyRow = ActiveCell.Row
MyCol = ActiveCell.Column
'FIND method to determine Last Row with Data, in a worksheet
Dim rng As Range
Set rng = ActiveSheet.Cells
lastRow = rng.Find(What:="*", After:=rng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
Range(Cells(2, MyCol), Cells(2, MyCol)).Copy Range(Cells(2, MyCol), Cells(lastRow, MyCol))
ActiveSheet.Calculate
Range(Cells(5, MyCol), Cells(lastRow, MyCol)).Value = Range(Cells(5, MyCol), Cells(lastRow, MyCol)).Value
Application.Calculation = xlAutomatic
End Sub
When running the macro on a sheet where the active range is small I am not having any issues. However, when I run the macro on a sheet with 66 columns and 900,000 rows Excel crashes. This was working on the larger dataset until a few days ago and I did not change anything.
I tried disabling COM add-ins and running in safe mode, however, I am getting the same results. Runs fine on smaller sheets, crashes on larger sheets.
When I step through the macro, it crashes at the line in bold below. Is there a maximum ActiveSheet.Cells range size that is causing issues?
Thanks for taking a look!
Sub CopyPasteFormulas()
Dim MyRow
Dim MyCol
Dim lastRow As Long
Application.Calculation = xlManual
MyRow = ActiveCell.Row
MyCol = ActiveCell.Column
'FIND method to determine Last Row with Data, in a worksheet
Dim rng As Range
Set rng = ActiveSheet.Cells
lastRow = rng.Find(What:="*", After:=rng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
Range(Cells(2, MyCol), Cells(2, MyCol)).Copy Range(Cells(2, MyCol), Cells(lastRow, MyCol))
ActiveSheet.Calculate
Range(Cells(5, MyCol), Cells(lastRow, MyCol)).Value = Range(Cells(5, MyCol), Cells(lastRow, MyCol)).Value
Application.Calculation = xlAutomatic
End Sub