Error when using command button to turn off auto calculation


Posted by Joe on December 01, 2000 10:04 AM

I'm trying to run code using a command button on a worksheet. I want to turn off automatic calculation at the beginning of the procedure. When I run the procedure with the command button, I get a run-time error '1004': "Method 'Calculation' of Object '_Application' failed." However, when I run the code without using the command button, it works fine. Here's my code, which is in the sheet object:

Private Sub CommandButton2_Click()
Application.Calculation = xlCalculationManual
.
.(Statements)
.
End Sub

Any ideas? Thanks in advance.
Joe

Posted by Ivan Moala on December 01, 2000 5:20 PM

(Statements)


Joe
You can do either 2 things;
1) In your code place code to select a range or cell
2) In the buttons properties / TakeFocusOnClick
SET this to false

either method will get you out of this problem.


Ivan



Posted by Joe on December 04, 2000 8:20 AM

Re: Thanks, Ivan

(Statements)

Ivan,
Both worked perfectly. Thanks.

Joe