This is just to get you started. Say by clicking the mouse button using the InsertIntoTables() buttons. I assume InsertIntoTables() is in the standard module . (this makes it easier to call from another sub)
First start:
Sub NumericEnter() Application.OnKey "{ENTER}", "InsertIntoTables" End Sub
After that:
- touching the ENTER key will have the same effect as clicking the button
- normal ENTER key will not be affected
To restore the ENTER numeric keypad, run this:
Sub ClearEnter() Application.OnKey "{ENTER}", "" End Sub
What you must do:
The numeric keypad ENTER will call your subtitle no matter which worksheet is active. You must add logic to determine which sheet is active and take appropriate action. You must choose which cell you want when your subcomponent is complete. You must remember to start recovery before exiting.
EDIT # 1:
I have two sheets; Sheet1 and Sheet2.
Sheet1 is the sheet in which I want to use the "special" ENTER key.
I placed the following in a standard module :
Sub NumericEnter() Application.OnKey "{ENTER}", "InsertIntoTables" End Sub Sub ClearEnter() Application.OnKey "{ENTER}", "" End Sub Sub InsertIntoTables() MsgBox "Inserting" End Sub
I placed the following in the area of ββthe page <1> :
Private Sub Worksheet_Activate() Call NumericEnter End Sub Private Sub Worksheet_Deactivate() Call ClearEnter End Sub
I placed the following in the code area of ββthe book :
Private Sub Workbook_BeforeClose(Cancel As Boolean) Call ClearEnter End Sub Private Sub Workbook_Open() Sheets("Sheet2").Activate Sheets("Sheet1").Activate End Sub
The purpose of the Workbook_Open() macro is to ensure that we start with the active Sheet1 and the active ENTER key.
EDIT # 2:
Use this instead:
Sub ClearEnter() Application.OnKey "{ENTER}" End Sub
Link:
Reply to Tim