Mega Code Archive

 
Categories / VisualBasic Script / Application
 

Use Application OnKey to register sub module with key stroke

Sub Setup_OnKey()     Application.OnKey "{PgDn}", "PgDn_Sub"     Application.OnKey "{PgUp}", "PgUp_Sub"     MsgBox "PgUp and PgDown have been re-mapped." End Sub Sub Cancel_OnKey()     Application.OnKey "{PgDn}"     Application.OnKey "{PgUp}"     MsgBox "PgUp and PgDown have been restored to normal." End Sub Sub PgDn_Sub()     On Error Resume Next     ActiveCell.Offset(1, 0).Activate End Sub Sub PgUp_Sub()     On Error Resume Next     ActiveCell.Offset(-1, 0).Activate End Sub