Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pause to Calc

I've got vba code that copies formulas into a range, calculates, then
copy/paste-values. Since there are lots of formulas, the calculation
takes 10 or 15 seconds, during which time the cursor shows an
hourglass. If the user just waits during this time, it works fine. But
if the user starts clicking around, the calculation doesn't work, and
the code finishes with bad values. It's as if the code changes the
formulas to values before the calculation is complete.

How do I make it so that the calculation is complete, regardless of
what the user does? One thing I'm thinking of is to have a pop up
message of "Please be patient..." or whatever to appear while the
calculation is going on. Would this help? Though I'm a skilled user of
vba, I have never done this specifically (having a pop up appear while
code runs in the background) and don't know how to do it.

Many thanks in advance.

Stuart
http://home.comcast.net/~sresnick2/mypage.htm

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Pause to Calc

Have a look here.
http://j-walk.com/ss/excel/tips/tip34.htm
Should be right up your alley for what you are after.

Corey....


wrote in message
ups.com...
I've got vba code that copies formulas into a range, calculates, then
copy/paste-values. Since there are lots of formulas, the calculation
takes 10 or 15 seconds, during which time the cursor shows an
hourglass. If the user just waits during this time, it works fine. But
if the user starts clicking around, the calculation doesn't work, and
the code finishes with bad values. It's as if the code changes the
formulas to values before the calculation is complete.

How do I make it so that the calculation is complete, regardless of
what the user does? One thing I'm thinking of is to have a pop up
message of "Please be patient..." or whatever to appear while the
calculation is going on. Would this help? Though I'm a skilled user of
vba, I have never done this specifically (having a pop up appear while
code runs in the background) and don't know how to do it.

Many thanks in advance.

Stuart
http://home.comcast.net/~sresnick2/mypage.htm



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Pause to Calc

Stuart,
May be sandwich your code in Application.Interactive=False/True statements.

Make sure you use an error handling with Application.Interactive=True, just
in case.

NickHK

wrote in message
ups.com...
I've got vba code that copies formulas into a range, calculates, then
copy/paste-values. Since there are lots of formulas, the calculation
takes 10 or 15 seconds, during which time the cursor shows an
hourglass. If the user just waits during this time, it works fine. But
if the user starts clicking around, the calculation doesn't work, and
the code finishes with bad values. It's as if the code changes the
formulas to values before the calculation is complete.

How do I make it so that the calculation is complete, regardless of
what the user does? One thing I'm thinking of is to have a pop up
message of "Please be patient..." or whatever to appear while the
calculation is going on. Would this help? Though I'm a skilled user of
vba, I have never done this specifically (having a pop up appear while
code runs in the background) and don't know how to do it.

Many thanks in advance.

Stuart
http://home.comcast.net/~sresnick2/mypage.htm



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Pause to Calc

wrote in message
ups.com...
I've got vba code that copies formulas into a range, calculates, then
copy/paste-values. Since there are lots of formulas, the calculation
takes 10 or 15 seconds, during which time the cursor shows an
hourglass. [snip]

You should avoid calculation of formulas during execution of your code:
Application.Calculation = xlCalculationManual
(your code goes here)
Application.Calculation = xlCalculationAutomatic

Joerg


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Pause to Calc

Many thanks to everyone who helped. The suggestion from NickHK below
worked fine.

In normal Excel use, if you're in manual calc mode, and you hit the
calc key, it will start to calc everything, but if you click on a cell
during this time, the calc will stop before it's complete. This seems
to be what happened with my code. When the code reached the "calculate"
line, if the user happened to click, the code would continue with the
next line without the calculation completing, resulting in bad results
when the formulas get replaced by values.

I sandwiched my "Calculate" line between the "application.interactive"
statements, and now if the user clicks during the code execution, it's
no problem.

Stuart

NickHK wrote:
Stuart,
May be sandwich your code in Application.Interactive=False/True statements.

Make sure you use an error handling with Application.Interactive=True, just
in case.

NickHK

wrote in message
I've got vba code that copies formulas into a range, calculates, then
copy/paste-values. Since there are lots of formulas, the calculation
takes 10 or 15 seconds, during which time the cursor shows an
hourglass. If the user just waits during this time, it works fine. But
if the user starts clicking around, the calculation doesn't work, and
the code finishes with bad values. It's as if the code changes the
formulas to values before the calculation is complete.

How do I make it so that the calculation is complete, regardless of
what the user does? One thing I'm thinking of is to have a pop up
message of "Please be patient..." or whatever to appear while the
calculation is going on. Would this help? Though I'm a skilled user of
vba, I have never done this specifically (having a pop up appear while
code runs in the background) and don't know how to do it.

Many thanks in advance.

Stuart
http://home.comcast.net/~sresnick2/mypage.htm


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calc = Manual & Do Not Calc b/4 SAVE Ken Excel Discussion (Misc queries) 0 October 3rd 07 02:28 PM
My calc key on Excel changes box to "Text" Box and doesn't calc ? jack Charts and Charting in Excel 0 August 8th 06 07:30 PM
Best way to pause? Ramthebuffs[_26_] Excel Programming 2 March 1st 06 03:48 AM
auto calc on, but have to edit (f2) cells to force re-calc..help! Curt Excel Worksheet Functions 3 February 13th 06 06:05 PM
Pause? Pete Fedrowitz Excel Programming 2 February 13th 04 06:05 PM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"