ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with using OnKey (https://www.excelbanter.com/excel-programming/348494-help-using-onkey.html)

keithb

Help with using OnKey
 
When included in the "ThisWorkbook" Module, this code does caused the named
procedures to run when the described keys are pressed. Furthermore, when a
subroutine in that module runs, this code causes an error message stating:
"Only comments may appear after an End Sub, End Function, or End Property".
Does that mean that this code needs to be included in a subroutine?

Application.OnKey "%{LEFT}", "ShiftLeft"
Application.OnKey "%{RIGHT}", "ShiftRight"

Thanks,

Keith



Jim Thomlinson[_5_]

Help with using OnKey
 
Yup. That code that you have there needs to be in a subroutine. As a guess in
thisworkbook you probably want to place it in the workbook open sub.
--
HTH...

Jim Thomlinson


"keithb" wrote:

When included in the "ThisWorkbook" Module, this code does caused the named
procedures to run when the described keys are pressed. Furthermore, when a
subroutine in that module runs, this code causes an error message stating:
"Only comments may appear after an End Sub, End Function, or End Property".
Does that mean that this code needs to be included in a subroutine?

Application.OnKey "%{LEFT}", "ShiftLeft"
Application.OnKey "%{RIGHT}", "ShiftRight"

Thanks,

Keith





All times are GMT +1. The time now is 06:33 PM.

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