ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Redefining the Ctrl [ and Ctrl ]s short cut with OnKey? (https://www.excelbanter.com/excel-programming/321417-redefining-ctrl-%5B-ctrl-%5Ds-short-cut-onkey.html)

John Wirt[_5_]

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
I would like to assign subroutines to two key sequences, default Excel
shortcut key sequences: Ctrl [ and Ctrl ].

Is this possible?

I placed this code in the "ThisWorkbook" module of PERSONAL.xls and got this
error: "Method 'OnKey' object '_Application' failed.

-------
Option Explicit
Private Sub Workbook_Open()
Application.OnKey "^[", "FindLinkedCell"
Application.OnKey "^[", "ReturnToCell"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^["
Application.OnKey "^]"
End Sub
---------

The the procedures execute and the keys are rediefined if I use Ctrl a
("^a") and Ctrl b.
John Wirt



Ron de Bruin

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Hi John

Use this
Application.OnKey "^{[}", "FindLinkedCell"



--
Regards Ron de Bruin
http://www.rondebruin.nl



"John Wirt" wrote in message ...
I would like to assign subroutines to two key sequences, default Excel
shortcut key sequences: Ctrl [ and Ctrl ].

Is this possible?

I placed this code in the "ThisWorkbook" module of PERSONAL.xls and got this
error: "Method 'OnKey' object '_Application' failed.

-------
Option Explicit
Private Sub Workbook_Open()
Application.OnKey "^[", "FindLinkedCell"
Application.OnKey "^[", "ReturnToCell"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^["
Application.OnKey "^]"
End Sub
---------

The the procedures execute and the keys are rediefined if I use Ctrl a
("^a") and Ctrl b.
John Wirt





John Wirt[_5_]

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Ron, Thank you. John




John Wirt[_5_]

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Unfortunately, this solution does not work (at least for me).

John

"Ron de Bruin" wrote in message
...
Hi John

Use this
Application.OnKey "^{[}", "FindLinkedCell"




Ron de Bruin

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Hi John

Do you see an error?

--
Regards Ron de Bruin
http://www.rondebruin.nl



"John Wirt" wrote in message ...
Unfortunately, this solution does not work (at least for me).

John

"Ron de Bruin" wrote in message
...
Hi John

Use this
Application.OnKey "^{[}", "FindLinkedCell"






John Wirt[_5_]

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Yes, the error is: Method 'OnKey' of object '_Application' failed.


The code is (copied):

Private Sub Workbook_Open()
Application.OnKey "^([)", "FindLinkedCell"
Application.OnKey "^(])", "ReturnToCell"
End Sub

John
----------------------------
"Ron de Bruin" wrote in message
...
Hi John

Do you see an error?

--
Regards Ron de Bruin
http://www.rondebruin.nl






Ron de Bruin

Redefining the Ctrl [ and Ctrl ]s short cut with OnKey?
 
Use a { and not a (



--
Regards Ron de Bruin
http://www.rondebruin.nl



"John Wirt" wrote in message ...
Yes, the error is: Method 'OnKey' of object '_Application' failed.


The code is (copied):

Private Sub Workbook_Open()
Application.OnKey "^([)", "FindLinkedCell"
Application.OnKey "^(])", "ReturnToCell"
End Sub

John
----------------------------
"Ron de Bruin" wrote in message
...
Hi John

Do you see an error?

--
Regards Ron de Bruin
http://www.rondebruin.nl









All times are GMT +1. The time now is 04:20 AM.

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