Hi,
I have a fairly sizable spreadsheet, and the whole thing grinds to a halt if calculations are on while forms are running. As such, I want to turn the calculations to manual while the forms are active, but turn them back to automatic when the form is closed.
Now, obviously:
Private Sub UserForm_Activate()
Application.Calculation = xlManual
End Sub
does the job of switching it to Manual, and the spreadsheet runs like a dream. The problem, however, is that the form is always closed by clicking the top-right-hand "X". And that would seem to NOT activate the following code:
Private Sub UserForm_Deactivate()
Application.Calculation = xlAutomatic
End Sub
Is there any way to trigger a command on a form being closed like that? Any other suggestions of devious ways of dealing with this that I haven't thought of?
I have a fairly sizable spreadsheet, and the whole thing grinds to a halt if calculations are on while forms are running. As such, I want to turn the calculations to manual while the forms are active, but turn them back to automatic when the form is closed.
Now, obviously:
Private Sub UserForm_Activate()
Application.Calculation = xlManual
End Sub
does the job of switching it to Manual, and the spreadsheet runs like a dream. The problem, however, is that the form is always closed by clicking the top-right-hand "X". And that would seem to NOT activate the following code:
Private Sub UserForm_Deactivate()
Application.Calculation = xlAutomatic
End Sub
Is there any way to trigger a command on a form being closed like that? Any other suggestions of devious ways of dealing with this that I haven't thought of?