Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

Worksheet_Calculate Event is also triggered in another Excel workbook?

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.
1 Solution
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

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
BoerdijkAuthor Commented:
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


Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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?
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
Question is PAQ'd and points refunded.

Community Support Moderator @Experts Exchange

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now