ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Key Press Event (https://www.excelbanter.com/excel-programming/355033-key-press-event.html)

Todd Huttenstine

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



All times are GMT +1. The time now is 11:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com