我可以从其他工作簿触发Workbook_SheetChange事件吗? [英] Can I trigger the Workbook_SheetChange event from a different workbook?

查看:62
本文介绍了我可以从其他工作簿触发Workbook_SheetChange事件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了

I found an awesome script that checks if multiple worksheets are selected when a cell is changed and warns the user.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
...

This prevents unintended changes if i have 10 worksheets selected and made a change on the visible worksheet.

I placed this script in the "ThisWorkbook" section of my "Personal" workbook. (This workbook automatically when Excel is open but is hidden). The problem is that it only triggers when a change is made to that "Personal" workbook so it's not checking to see what I am doing in any other workbook.

Is there anyway to trigger this action on any open workbook, without actually placing the script in that workbook? Also, if you found any questions in StackOverflow that cover this, please let me know. I couldn't find any. Thanks!

解决方案

Excel Application Events Reference

You can use WithEvents to trap the Excel.Application Events.


Private WithEvents ExcelApp As Excel.Application

Private Sub Workbook_Open()
    Set ExcelApp = Application
End Sub

这篇关于我可以从其他工作簿触发Workbook_SheetChange事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆