ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assigning a macro to the tab key (https://www.excelbanter.com/excel-programming/372401-assigning-macro-tab-key.html)

Bill K

assigning a macro to the tab key
 
I would like to assign a macro to run whenever the tab key is pressed could
anyone help?
thanks
--
bill k

Jim Thomlinson

assigning a macro to the tab key
 
You can do it but you need to be carefull with this type of code. It is
application level code so it is in effect for all of Excel, not just the
current workbook. You may want to handle this code using the following events
to get the code initialized and deactivated as necessary.

Workbook Open, Close, Activate and Deactivate

Sub DoTab()
Application.OnKey "{TAB}", "MyMacro"
End Sub

Sub UndoTab()
Application.OnKey "{TAB}"
End Sub
--
HTH...

Jim Thomlinson


"Bill K" wrote:

I would like to assign a macro to run whenever the tab key is pressed could
anyone help?
thanks
--
bill k



All times are GMT +1. The time now is 11:56 PM.

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