ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_Calculate event problem (https://www.excelbanter.com/excel-programming/315141-worksheet_calculate-event-problem.html)

Otto Moehrbach[_6_]

Worksheet_Calculate event problem
 
Excel 2002, WinXP
I have a sheet with many formulas. That sheet will calculate whenever the
file is opened. That will trigger the Worksheet_Calculate macro that I
have, and that is the beginning of my problem.
The macro consists of one line:
Private Sub Worksheet_Calculate()
If ActiveSheet.Name < Range("AA1").Value Then Call MyMacro
End Sub

My problem is that MyMacro is being called at times when I'm not expecting
it. I believe that what is happening is that specific sheet is
automatically calculating, like at opening of the file, when that sheet is
not the ActiveSheet. That causes the call to MyMacro.

I need to copy this code on to many other sheet modules, so I don't want to
use the name of the sheet.
Question. How can I code the above event macro so that the code will look
at only the name of the sheet and the contents of cell AA1 of the sheet in
which the code is written?
For your info, I am trying to prevent anyone from changing the sheet name of
any of these sheets. Right now this code is in only one of those sheets.
Thanks for your help. Otto



Frank Kabel

Worksheet_Calculate event problem
 
Hi
use
me.name
in your event handler

--
Regards
Frank Kabel
Frankfurt, Germany

"Otto Moehrbach" schrieb im Newsbeitrag
...
Excel 2002, WinXP
I have a sheet with many formulas. That sheet will calculate

whenever the
file is opened. That will trigger the Worksheet_Calculate macro that

I
have, and that is the beginning of my problem.
The macro consists of one line:
Private Sub Worksheet_Calculate()
If ActiveSheet.Name < Range("AA1").Value Then Call MyMacro
End Sub

My problem is that MyMacro is being called at times when I'm not

expecting
it. I believe that what is happening is that specific sheet is
automatically calculating, like at opening of the file, when that

sheet is
not the ActiveSheet. That causes the call to MyMacro.

I need to copy this code on to many other sheet modules, so I don't

want to
use the name of the sheet.
Question. How can I code the above event macro so that the code will

look
at only the name of the sheet and the contents of cell AA1 of the

sheet in
which the code is written?
For your info, I am trying to prevent anyone from changing the sheet

name of
any of these sheets. Right now this code is in only one of those

sheets.
Thanks for your help. Otto




Otto Moehrbach[_6_]

Worksheet_Calculate event problem
 
Frank
That one had me stumped. It's going into my HowTo file. Thanks. Otto
"Frank Kabel" wrote in message
...
Hi
use
me.name
in your event handler

--
Regards
Frank Kabel
Frankfurt, Germany

"Otto Moehrbach" schrieb im Newsbeitrag
...
Excel 2002, WinXP
I have a sheet with many formulas. That sheet will calculate

whenever the
file is opened. That will trigger the Worksheet_Calculate macro that

I
have, and that is the beginning of my problem.
The macro consists of one line:
Private Sub Worksheet_Calculate()
If ActiveSheet.Name < Range("AA1").Value Then Call MyMacro
End Sub

My problem is that MyMacro is being called at times when I'm not

expecting
it. I believe that what is happening is that specific sheet is
automatically calculating, like at opening of the file, when that

sheet is
not the ActiveSheet. That causes the call to MyMacro.

I need to copy this code on to many other sheet modules, so I don't

want to
use the name of the sheet.
Question. How can I code the above event macro so that the code will

look
at only the name of the sheet and the contents of cell AA1 of the

sheet in
which the code is written?
For your info, I am trying to prevent anyone from changing the sheet

name of
any of these sheets. Right now this code is in only one of those

sheets.
Thanks for your help. Otto







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

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