LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Excel Range calculation breaking application.calculate - horrifyingproblem

Hi,

I've got a horrible Excel / vba problem. I run a simulation model
which basically loops through some code several thousand times - each
time doing a calculation of a few worksheets. Its important to
optimise the calculations, as they take forever otherwise. The
optimisation process went like this:

(1)
start loop
application.calculate
end loop

this became:

(2)
start loop
calculate only the sheets needed
end loop

this became

(3)
start loop
calculate only the ranges needed on the sheets needed
end loop


approach (3) was orders of magnitude faster, however it appears to
have issue that it breaks application.calculate, which is need
elsewhere in the code (after the loop). Code snippet below:

***
Start Loop

' useful code
'calculate only needed ranges
.Worksheets("Sim Curves").Range("B6:CH34").Calculate
.Worksheets("Sim Curves").Range("B39:CH66").Calculate

' useful code
End loop

application.calculate ' <--- this calculate works
application.calculate ' <--- this one doesn't
***


The second application.calculate doesn't work. In addition, a
sheets.calculate also doesn't work, though a range.calculate does.

It gets worse. Consider the following code snippet:

***
Start Loop

' useful code
'calculate only needed ranges
.application.calculate ' calc(1)
.Worksheets("Sim Curves").Range("B6:CH34").Calculate
.Worksheets("Sim Curves").Range("B39:CH66").Calculate
. application.calculate ' calc(2)
' useful code
End loop

application.calculate ' <--- this calculate works
application.calculate ' <--- this one also works
***

In this case, application.calculate doesn't break. If you try to
remove calc(1) however, it would. Obviously if both (1) and (2) are
removed, we're in the same position as earlier and calculation breaks.

I have no idea where to begin with this, it seems totally illogical.
Any help would be very greatfully received.

Cheers

Chris





 
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
Manual Calculation in Excel 2007 with Calculate mode set to Automatic Julie White Excel Worksheet Functions 1 November 24th 09 09:38 PM
sumproduct calculation does not calculate entire range John Gregory Excel Discussion (Misc queries) 5 September 11th 09 09:16 PM
Help!Excel will not calculate formulas- Not in manual calculation Lisa Excel Worksheet Functions 6 December 9th 08 12:47 PM
Breaking out Dates from a Date Range WPNX777 Excel Discussion (Misc queries) 1 December 4th 08 08:48 PM
microsoft excel does not calculate - Automatic calculation is enab Schumi Excel Discussion (Misc queries) 1 November 2nd 05 08:34 PM


All times are GMT +1. The time now is 09:51 PM.

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

About Us

"It's about Microsoft Excel"