ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restrict Worksheet_Calculate() to its original worksheet !!! (https://www.excelbanter.com/excel-programming/328500-restrict-worksheet_calculate-its-original-worksheet.html)

Carim[_3_]

Restrict Worksheet_Calculate() to its original worksheet !!!
 
Hi,

I have to use worksheet calculate to fire a couple of macros.
The problem is that, at a later stage, another workbook is opened, and
worksheet_calculate() fires automatically in the newly opened workbook.
So far, I had no success in adding a trap such as :
If ActiveSheet.Name <"xxxx" Then exit sub ...
Any suggestions ???
Thanks in advance
Carim


Bernie Deitrick

Restrict Worksheet_Calculate() to its original worksheet !!!
 
Carim,

Add this to the top of your event code:
Application.EnableEvents = False

And this to the bottom:
Application.EnableEvents = True

Of course, that may prevent the auto_open macro or the workbook_open event
of the workbook that you are opening from running, so there will be some
further testing on your part involved.

HTH,
Bernie
MS Excel MVP

"Carim" wrote in message
oups.com...
Hi,

I have to use worksheet calculate to fire a couple of macros.
The problem is that, at a later stage, another workbook is opened, and
worksheet_calculate() fires automatically in the newly opened workbook.
So far, I had no success in adding a trap such as :
If ActiveSheet.Name <"xxxx" Then exit sub ...
Any suggestions ???
Thanks in advance
Carim




Carim[_3_]

Restrict Worksheet_Calculate() to its original worksheet !!!
 
Hi Bernie,

It is already part of worksheet_calculate ...
As a matter of fact, the very same module tested on an empty
sheet/workbook works fine...
The problem is that a pivot table object is in this sheet, which seems
to disturb "normal behaviours" ...
Thanks for your comments
Cheers
Carim



All times are GMT +1. The time now is 12:43 PM.

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