|
楼主 |
发表于 2013-12-11 23:14
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
受C#代码启发,自己研究出来了,这样就不用在每个工作表中写代码了,只写一段,所有工作簿通用:- Imports Microsoft.Office.Tools.Ribbon
- Imports Microsoft.Office.Interop.Excel
- Public Class ThisAddIn
- Private Sub ThisAddIn_Startup() Handles Me.Startup
- AddHandler Me.Application.SheetSelectionChange, AddressOf Application_SheetSelectionChange
- AddHandler Me.Application.SheetChange, AddressOf SHEETCH
- End Sub
- Private Sub Application_SheetSelectionChange(Sh As Object, Target As Range)
- MsgBox("选择区域发生改变")
- End Sub
- Private Sub SHEETCH(SH As Object, TARGET As Range)
- MsgBox("工作表发生改变")
- End Sub
- Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
- RemoveHandler Me.Application.SheetSelectionChange, AddressOf Application_SheetSelectionChange
- RemoveHandler Me.Application.SheetChange, AddressOf SHEETCH
- End Sub
- End Class
复制代码 |
|