Microsoft KB Archive/838021

= The speed of iterations in a VBA macro that uses the Calculate method decreases as the macro runs in Excel 2002 =

Article ID: 838021

Article Last Modified on 7/1/2005

-

APPLIES TO


 * Microsoft Excel 2002 Standard Edition

-



SYMPTOMS
In 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.



CAUSE
This 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



WORKAROUND
Microsoft 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

Keywords: kbprb KB838021

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.