View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Charlie Charlie is offline
external usenet poster
 
Posts: 703
Default calculationstate

Maybe try

Application.EnableEvents = False
Application.Calculate
Application.EnableEvents = True


"Kris" wrote:

Tom Ogilvy wrote:
to the best of my knowledge, Calculate doesn't operate asynchronously, so it
shouldn't be an issue.


When I put break after calculate and I look at call stack I have


vbaproject.sheet1.worksheet.change
<non basic code
vbaproject.udf.myfun


udf is my module

it means that myfun which is a udf function was called by excel from one
of cells, this function was interrupted by excel and my code in
worksheet_change event is continued.
When worksheet_change is finished excel goes back and finishes calculation.

But I can't continue worksheet_change without calculated values in cells.








If it is for some reason, then break your code into two pieces (calculate at
the end of the first). Then use Application.OnTime to start the second
section of code with an appropriate delay.


Calculation time is now 5 seconds, I can't add any second more.