Worksheet_Calculate event problem

O

Otto Moehrbach

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top