Error using "Calculate" function in VB

  • Thread starter Thread starter deltree
  • Start date Start date
D

deltree

Hi all,

I have been experiencing some problems with the "Calculate" function in
an Excel macro, and after consulting the Microsoft MSDN resources for
over an hour to no avail, now I turn to you guys for help.

I've used the Calculate function in my workbook for weeks now without a
problem, but all of a sudden the function stopped working. Now whenever
my VB code encounters a Calculate statement, it throws this error:

"Runtime error 1004: Cannot run Visual Basic macro because of a syntax
error."

I have tried using "Application.Calculate" instead of just "Calculate",
but that does not stop the error. Also, I have tried turning off and on
automatic calculation, but that does not help, either.

Interestingly, I have found that the Worksheets.Calculate function
_does_ work. So right now I am using a workaround that calculates each
sheet individually, but this solution is too slow to use permanently.

Any thoughts on what might be causing this strange error??

Thanks for your help - I really appreciate it.

Cheers,
Deltree

P.S. I won't bother quoting my VB code, because it's pretty
sophisticated (over 50 subroutines) and _none_ of the Calculate
statements work.
 
Hi Deltree,

Have you compiled your code ( VBE-->debug-->compile vba project), and if so
does it highlight a syntax error?

Is this VB6 code or VBA code?

are the calculate statements in a general module or a class module?

Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm
 
Charles,

I tried recompiling my VBA probject, and the Calculate function work
just fine. Thanks!!

BTW, I was using VB6 code, and the calculate statements were in
general module, not a class module.

Deltre
 
Back
Top