Thread: Key Press Event
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine Todd Huttenstine is offline
external usenet poster
 
Posts: 40
Default Key Press Event

Hey

I need to be able to have a msgbox pop up when the user hits CTRL +
SHIFT in a cell on an Excel worksheet.

Lets say the user selects cell A1. Then at anytime after A1 has been
selected and the user presses those keys, I need for it to trigger a
msgbox to pop up. Is this possible and if so, how would I do this?


Below is some code I found that works, but how do I make it work when
the user hits CTRL + SHIFT from an active cell?

'This code goes in the top of the module of your choice
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer

Private Const VK_CONTROL = &H11
Private Const VK_SHIFT = &H10

'Then this code goes in the event of your choice (same module as where
above code is)
If GetAsyncKeyState(VK_CONTROL) < 0 Then
If GetAsyncKeyState(VK_SHIFT) < 0 Then
MsgBox "Test"
End If
End If