Fire_Chief
Well-known Member
- Joined
- Jun 21, 2003
- Messages
- 693
- Office Version
- 365
- Platform
- Windows
Is there a way I can press a number or a letter and have a sub routine run. I don't want a button on the page?
Thank You
Thank You
[FONT=Courier New][COLOR=black]Option Explicit [/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub StartKey()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] Application.OnKey "D", "MyProcedure"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub EndKey()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] Application.OnKey "D"[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Sub MyProcedure()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] MsgBox "My OnKey is active", 0, vbNullString[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]'Thisworkbook module[/COLOR][/FONT]
[FONT=Courier New][FONT=Verdana][COLOR=black]Option Explicit[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Private Sub Workbook_Activate()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] Call StartKey[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]Private Sub Workbook_Deactivate()[/COLOR][/FONT]
[FONT=Courier New][COLOR=black] Call EndKey[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]End Sub[/COLOR][/FONT]
[/FONT]