ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Infinite loop using Worksheet_Calculate (https://www.excelbanter.com/excel-discussion-misc-queries/117336-infinite-loop-using-worksheet_calculate.html)

Parker

Infinite loop using Worksheet_Calculate
 
I'd like to update multiple cells using a Worksheet_Calculate code. My
problem is that the sheet is calculating after each one is updated and
triggers the macro again so it never stops. It works perfectly if I only
update one cell or switch to manual calculate. Is there any way around this?

Nick Hodge

Infinite loop using Worksheet_Calculate
 
The worksheet_calculate event will fire, as it's name implies, everytime the
worksheet calculates. If you change a cell that has a dependency then it
will calculate.

Perhaps an explanation of what you are trying to do may help, as I believe a
worksheet_change event, which can control the cell(s) that are changing may
be a better way to go

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England

HIS
www.nickhodge.co.uk

"Parker" wrote in message
...
I'd like to update multiple cells using a Worksheet_Calculate code. My
problem is that the sheet is calculating after each one is updated and
triggers the macro again so it never stops. It works perfectly if I only
update one cell or switch to manual calculate. Is there any way around
this?




Dave Peterson

Infinite loop using Worksheet_Calculate
 
Maybe you can surround the code that causes calculation with:

application.enableevents = false
'whatever code you have
application.enableevents = true



Parker wrote:

I'd like to update multiple cells using a Worksheet_Calculate code. My
problem is that the sheet is calculating after each one is updated and
triggers the macro again so it never stops. It works perfectly if I only
update one cell or switch to manual calculate. Is there any way around this?


--

Dave Peterson


All times are GMT +1. The time now is 03:44 PM.

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