Re-establish function on exiting workbook

C

Colin Hayes

HI All

I use this code to turn Automatic Calculation to Manual when I open my
workbook :


Private Sub Workbook_Open()


With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub



Can someone advise how to extend this so that it switches Automatic
Calculation back on when I close the workbook?



Thanks
 
R

Rick Rothstein

Why turn Automatic calculation back on when you close the workbook if you
are just going to turn it back off when you open it again? If you want the
cells updated for any changes made, just issue a Calculate or CalculateFull
method in the BeforeClose event.
 
S

Shane Devenshire

Hi,

Use the BeforeClose event. Here is a sample:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
End Sub
 
C

Colin Hayes

Shane said:
Hi,

Use the BeforeClose event. Here is a sample:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
End Sub


Hi

OK Thanks for that.

How would this merge with my existing code?

Here is what I have presently

Private Sub Workbook_Open()


With Application
.Calculation = xlManual
.MaxChange = 0.001
.CalculateBeforeSave = False
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub



Do I combine the two somehow?

Best wishes.
 
C

Colin Hayes

Rick Rothstein said:
Why turn Automatic calculation back on when you close the workbook if you
are just going to turn it back off when you open it again? If you want the
cells updated for any changes made, just issue a Calculate or CalculateFull
method in the BeforeClose event.

HI

Well , because I'm running other workbooks which need Automatic
Calculation to been. It's only this one that needs it off when it's
running. When I close this one , I just need a way to have it switch
auto calculation back on , otherwise it interferes with the other
Workbooks. I'm not sufficiently technical to be able to implement your
suggestion , I'm afraid.

Best wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top