Thursday, October 29, 2009

VBA: Get pressed key


Declare Function GetKeyState Lib "user32" _(ByVal nVirtKey As Long) As Integer
Const VK_CONTROL As Integer = &H11 'Ctrl
Sub test()
If GetKeyState(VK_CONTROL) < 0 Then
Ctrl = True
Else Ctrl = False
If Ctrl = True Then
MsgBox "pressed"
Else
MsgBox "Not" End IfEnd Sub

'And this in the sheet module
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call test
End Sub

0 comments: