ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_SheetCalculate Method (https://www.excelbanter.com/excel-programming/436458-workbook_sheetcalculate-method.html)

chad

Workbook_SheetCalculate Method
 
Whenever the worksheet recalculates, I call a function that I have created.
However, the function apprars to run twice even though I am calling it once.
It the worksheet calcuating more than once? How can I fix this?

Thanks in advance for your help.



Tim Williams[_2_]

Workbook_SheetCalculate Method
 
Is your code a UDF, or called from the worksheet calculate event ?
What does your function do ?

Tim

"Chad" wrote in message
...
Whenever the worksheet recalculates, I call a function that I have
created.
However, the function apprars to run twice even though I am calling it
once.
It the worksheet calcuating more than once? How can I fix this?

Thanks in advance for your help.





Paul C

Workbook_SheetCalculate Method
 
Calling the function is probably triggering a new recalc event and causing
the macro to rerun.

In your event code put the following at the beginning

Application.EnableEvents=False
This prevents events from triggering.

and then at the end turn back on the triggering.
Application.EnableEvents=True

If you crash or are debugging your event triggering may be left turned off
run a simple one liner to restore. (For some reason when I am testing event
triggered code I always forget this)

sub fixme()
Application.EnableEvents=true
End Sub
--
If this helps, please remember to click yes.


"Chad" wrote:

Whenever the worksheet recalculates, I call a function that I have created.
However, the function apprars to run twice even though I am calling it once.
It the worksheet calcuating more than once? How can I fix this?

Thanks in advance for your help.




All times are GMT +1. The time now is 12:35 AM.

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