Calculations require application restart

cpupartsplz

New Member
Joined
Oct 18, 2006
Messages
14
Hey guys, I could use some help here.

I have a ~7MB spreadsheet with multiple tabs and thousands of rows of data across different sheets. I also utilize macros to process new data and recalculate formulas across different tabs based on a reference data tab.
After I run a macro (code below), the Automatic and Manual (F9) calculations don't seem to work. If I exit and reopen the Excel file, the formulas will calculate properly again.

I am not sure if this is a memory/cache issue or I am doing something in the macro that messes up the ability to calculate. Has anyone seen anything like this before?
I was thinking there may be a fix where I can clear the memory/cache to fix it?

VBA Code:
Sub Test()
'
' Test Macro
'
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    
    Sheets("Test").Select
' Clear Test Contents
    Cells.Select
    Selection.ClearContents
' Paste Test Data
    Range("A1").Select
    ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
        DisplayAsIcon:=False, NoHTMLFormatting:=True
' Remove Unnecessary Test Data
    Range("B:H,J:N").Select
    Selection.ClearContents
    Range("2:3,5:7").Select
    Selection.ClearContents
' Calculate
     Calculate
    'Application.Calculate
' Clear Copy Contents
    Sheets("Copy").Select
    Range("C2:C5001,J2:J5001").Select
    Selection.ClearContents
' Copy Test 1 Data
    Sheets("Test").Select
    Range("A8:A5000").Select
    Selection.Copy
' Paste Test 1 Data
    Sheets("Copy").Select
    Range("C3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
' Copy Test 2 Data
    Sheets("Test").Select
    Range("I10:I5000").Select
    Selection.Copy
    Range("A1").Select
' Paste Test 2 Data
    Sheets("Copy").Select
    Range("J3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C1").Select
' Calculate
    Calculate
   'Application.Calculate
    Application.ScreenUpdating = True

End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Well, you set Calculation in manual mode, so you need to restore it to automatic before completing the macro.
Add the line marked <<< ADD:
VBA Code:
' Calculate
    Application.Calculation = xlCalculationAutomatic      '<<< ADD THIS LINE HERE
    Calculate
   'Application.Calculate
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Well, you set Calculation in manual mode, so you need to restore it to automatic before completing the macro.

Thanks for the response. I did that consciously so it didn't automatically run the calculation immediately after the macro finishes. The calculation should still run manually by pressing F9. In the spirit of troubleshooting, I switched it back to automatic, but it still doesn't calculate for some reason until a restart of the application.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top