manual calculation only when a specific workbook is activated

andreagiugio

New Member
Joined
Oct 22, 2015
Messages
30
Hello,

I would like to set manual calculation when a workbook called "AMS" is activated.
The other workbooks should be always in automatic calculation.
Moreover if the workbook called "AMS" is activated and then closed and saved..the other workbooks should always be in automatic calculation.

Could you please help? I am getting mad. :LOL:

Thanks!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hello,

I would like to set manual calculation when a workbook called "AMS" is activated.
The other workbooks should be always in automatic calculation.
Moreover if the workbook called "AMS" is activated and then closed and saved..the other workbooks should always be in automatic calculation.

Could you please help? I am getting mad. :LOL:

Thanks!
Hi andreagiugio, try this:

- Press ALT+F11 to open the VBA Developer window
- Find the name of your workbook in the Project Pane in the top left of the window
- Right-click on ThisWorkbook and select View Code
- Copy / paste in the following 3 macros:

Code:
Private Sub Workbook_Activate()
Application.Calculation = xlCalculationManual
End Sub

Code:
Private Sub Workbook_Deactivate()
Application.Calculation = xlCalculationAutomatic
End Sub

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.Calculation = xlCalculationAutomatic
End Sub
 
Last edited:
Upvote 0
Hi andreagiugio, try this:

- Press ALT+F11 to open the VBA Developer window
- Find the name of your workbook in the Project Pane in the top left of the window
- Right-click on ThisWorkbook and select View Code
- Copy / paste in the following 3 macros:

Code:
Private Sub Workbook_Activate()
Application.Calculation = xlCalculationManual
End Sub

Code:
Private Sub Workbook_Deactivate()
Application.Calculation = xlCalculationAutomatic
End Sub

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.Calculation = xlCalculationAutomatic
End Sub


It works!! Thanks!!!!!
just a question: what is Workbook_BeforeClose ?
 
Upvote 0
It works!! Thanks!!!!!
just a question: what is Workbook_BeforeClose ?
Happy to help.

You said that you wanted it so that calculation goes back to automatic if that workbook gets closed, and as the name suggests it is a macro that runs when you close the workbook containing the code ;)

The (Cancel As Boolean) part basically means that if you go to close the workbook but then choose Cancel from the SaveAs dialog box then the code does not run, meaning the calculation remains manual until you either close the workbook or make a different one active.
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,673
Members
449,248
Latest member
wayneho98

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