Excel VBA多次双击操作

时间:2018-11-07 01:25:23

标签: excel vba double-click

当双击它时,我有一些代码可以将一个单元格中的日期增加1天。但是要重复一遍,我首先必须在单元格外部单击。

是否不可能连续执行多个双击动作?

1 个答案:

答案 0 :(得分:0)

这就是Cancel中的Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)进入的地方。

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    Rem: Increment your date

    Cancel = True   '<-- Set to true

End Sub

如果您只想在B列中取消预订,因为那是您的日期所在,那么:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    Rem: Only Cancel if double-clicked in column B
    If Not Intersect(Target, Me.Columns("B")) Is Nothing Then

        Cancel = True   '<-- Set to true

    End If

End Sub