ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error using "Calculate" function in VB (https://www.excelbanter.com/excel-programming/287434-error-using-calculate-function-vbulletin.html)

deltree

Error using "Calculate" function in VB
 
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.


---
Message posted from http://www.ExcelForum.com/


Charles Williams

Error using "Calculate" function in VB
 
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

"deltree " wrote in message
...
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.


---
Message posted from http://www.ExcelForum.com/




deltree[_2_]

Error using "Calculate" function in VB
 
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

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 06:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com