The speed of iterations in a VBA macro that uses the Calculate method decreases as the macro runs in Excel 2002 (838021)
The information in this article applies to:
SYMPTOMSIn Microsoft Excel 2002, when you run a Microsoft Visual
Basic for Applications (VBA) macro that uses the Calculate method to perform
many iterations, the speed of each successive iteration may
decrease.CAUSEThis problem may occur if you run a VBA macro that was
written for an earlier version of Microsoft Excel that uses the Calculate
method as in the following example: Worksheets(InputSheet).Calculate WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, perform a version check
in your macro to determine the current version of Excel to use the correct
calculation method in your VBA macro as in the following example:
Sub DoVersionSpecificCalc()
Dim str As String
Dim ver As Long
str = Application.Version
ver = Left(str, 2)
If (ver < 10) Then
Worksheets(InputSheet).Calculate
Else
Application.CalculateFull
End If
End Sub
Modification Type: | Major | Last Reviewed: | 7/1/2005 |
---|
Keywords: | kbprb KB838021 kbAudEndUser |
---|
|