View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Bundy John Bundy is offline
external usenet poster
 
Posts: 772
Default Key events on user form

Modify this to do tab or enter or shift or whatever you want. Originally
posted by Ron DeBruin, tests for Control key being pressed. If you need help
modifying post.

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


--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Ken Warthen" wrote:

I'm trying to capture the keycodes so that the focus will move to a specific
control based on whether the user hits TAB or ENTER, or SHIFT+TAB after
entering data in a given text box on my form. I've been trying to do so from
the Key_Down event of the text box, but am not having much luck. Any help
will be greatly appreciated.