|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 cgx5871 于 2018-7-6 11:59 编辑
需求:工作表上, 鼠标右键点击时, 判断"选中区域"是否改变.
-------------------------
在已选中区域右键点击, 不会触发Worksheet_SelectionChange事件!
有没有办法把这个当作判断条件来使用..,
下面的代码求指教:
- Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
- If SelectionSave.Address <> Target.Address Then
- MsgBox "区域已改变"
- Else
- MsgBox "原区域"
- End If
- End Sub
- Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If TypeName(SelectionSave) <> "Range" Then Set SelectionSave = Target: Exit Sub
- If SelectionSave.Address <> Target.Address Then Set SelectionSave = Selection
- End Sub
复制代码
|
|