?
Solved

Worksheet_Calculate Event is also triggered in another Excel workbook?

Posted on 2003-02-22
6
Medium Priority
?
395 Views
Last Modified: 2010-04-07
I hope someone can help me with the following problem:

I have written a Worksheet_Calculate Event for a particular worksheet in a particular workbook. I assumed that this event will only be triggered in that particular worksheet and in that particular workbook. But it seems that this event is also triggerd when I switch to another Excel workbook that I have open, and change a cell overthere. I don't want this, and I don't understand why he is doing that. Please help.

Best Regards.
 
0
Comment
Question by:Boerdijk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7998563
Hello Boerdijk,

try to use it in the workbook event

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
  if sh.name = "MySheet" then
  'dosomething here
  end if
End Sub

you can test for the sh object first to check it's the correct sheet you want to act on

HAGD:O)Bruintje
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7998777
Another way of preventing this is turning off autocalculate in excel, which is triggered also on close of a workbook . but then you need to turn it on again and every caculation you need has to be called on the worksheet.calculate event
0
 

Accepted Solution

by:
Boerdijk earned 0 total points
ID: 7999719
Hello bruintje

Thanks for your suggested solution, but unfortunately it doesn't work.

The workaround I found out myself in the meantime, is to add the condition:

If ActiveWorkbook.Name = "MyWorkbook" and ActiveSheet.Name = "MySheet" Then

'do something here

End if

That is also working in the Worksheet_Calculate event. But I still find it strange why this condition should be added if the event itself is already written in "MyWorkbook" and "MySheet".

I'm still puzzled why this event is triggered in another workbook if you don't add the condition.

If you or anyone has the explanation and/or a better solution to solve this, please tell me. Thanks

Regards.


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:CleanupPing
ID: 8901266
Boerdijk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8964135
Boerdijk, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:YensidMod
ID: 9104351
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question