AmateurExcelUser
New Member
- Joined
- Apr 7, 2014
- Messages
- 14
I have set up a Userform in Excel 2013 with lots of Toggle and Command Buttons. I want to be able to set up some Function Keys (eg F1 to F5) that run some of the same procedures called by the Command buttons, so that the user has a choice of either clicking a Command button or pressing F2 (for example). However, I cannot get the OnKey event to work. As a simple test, I have set up the code blow in module1. The Userform (which works) is called by a separate procedure in the same Module1 using .Show. When I run this, the MsgBox does not pop up when I hit F2 from the shown Userform.
Thanks very much in anticipation for any help!
Sub SetUp_OnKey()
Application.Onkey "{F2}", "F2_Sub"
End Sub
Sub F2_Sub()
Msgbox "F2 pressed" 'obviously when I get this working I can run a sub procedure here
End Sub
Thanks very much in anticipation for any help!
Sub SetUp_OnKey()
Application.Onkey "{F2}", "F2_Sub"
End Sub
Sub F2_Sub()
Msgbox "F2 pressed" 'obviously when I get this working I can run a sub procedure here
End Sub