View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Haw can i test if CTRL is activated (hold down) in VBA

Hi excelent

This in a normal module

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 If
End Sub



And this in the sheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call test
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl



"excelent" wrote in message ...
I wana use it in a event handle like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
if not CTRL is pressed (hold down) then exit sub ???

haw do i test for that ?

tanks in advanse