![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 10
|
I have a sub routine that runs really slowly unless the calculation method is set to manual. I can run the sub from the VB window OK (the sub is in Module 1) but if I try to run it from a button on a worksheet I get a "Method 'calculation' of object 'application' failed" error message.
The line of code I'm using is: Application.Calculation = xlCalculationManual This is really driving me mad. Can anyone help? JohnnyC |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
It might be that your calculation is already set to manual. Might be worth trying this instead: -
With Application If .Calculation <> xlCalculationManual Then .Calculation = xlCalculationManual End If End With |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 10
|
...just tried that. Calculation was not already set to manual, it runs through to the next line and gives the same error message.
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
Sorry, this runs OK for me, whichever way I call it. Could you post the rest of your code, just to see if something else is causing it?
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Posts: 10
|
OK, I've just put a line of code in front of the section you sent me which selects a different worksheet.
That was the only change I made and the macro runs fine now... Thanks for your help anyway. |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
If so then anothr way around this is to set your cmd button to; TakeFocus******* = False |
|
|
|
|
|
|
#7 |
|
New Member
Join Date: Apr 2002
Posts: 10
|
Completely right. I am using Excel 97. That button focus thing must have caused me a LOT of problems!
Thanks for the tip. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|