如何通过按工作表上的按钮来调用此功能?我希望能够确保我的宏运行,目前它只有在我打开代码然后在最后一个结束子之后按 enter 时才会运行。
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Key As Integer
If Target.Count > 1 Then Exit Sub
Key = GetKeyState(MOUSEEVENTF_LEFTDOWN)
If Key And 1 Then
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
Application.EnableEvents = False
Target.Resize(1, 2).Select
Application.EnableEvents = True
End If
Cancel = True
End If
End Sub