简体   繁体   English

使用Ctrl作为Worksheet_SelectionChange的修改器

[英]Use Ctrl as modifier on Worksheet_SelectionChange

I would like to open a form when a locked cell is clicked in a specific way (double click, key modifiers, etc). 我想以特定方式(双击,按键修饰符等)单击锁定的单元格时打开一个表单。

If I use Worksheet_BeforeDoubleClick , it will show a warning after closing the form, stating that the cell is locked (which is annoyting). 如果我使用Worksheet_BeforeDoubleClick ,它将在关闭表单后显示警告 ,说明该单元格已锁定(这很烦人)。

If I use Worksheet_SelectionChange , no warning will appear, but the form will appear every time a cell is selected (which is a bit much). 如果我使用Worksheet_SelectionChange ,则不会出现警告 ,但是每次选择一个单元格都会显示该表单(有点多)。

Is there anyway to use a modifier, like Ctrl , combined with Worksheet_SelectionChange , so that the user has to make an active choice to open the form? 无论如何,是否有使用修饰符(如Ctrl )和Worksheet_SelectionChange结合使用,以便用户必须主动选择才能打开表单?

Just set Cancel = True at the end of your Worksheet_BeforeDoubleClick sub. 只需在Worksheet_BeforeDoubleClick子代码的末尾设置Cancel = True

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    MsgBox "test"
    Cancel = True
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM