Listobjects: How to show a userform when user clicks on Tab


I have a listobject called "Orders". As all my entries to the datatable are added by userforms, I want to prevent the user from manually adding data at the end of the table by pressing TAB. I'd like to display a userform called frmOrders instead.

What code should I write?

Thanks for your help

Massimo ScolaAsked:
Who is Participating?
Elton PascuaCommented:
You can substitute myMacro with the actual sub procedure name.

Private Sub Workbook_Open()
    Application.OnKey "{Tab}", "myMacro"
End Sub

Open in new window

Massimo ScolaAuthor Commented:
Thanks for your code techfanatic
This code does not work as I've got several worksheets in my workbook.
I tried adding this code to the Worksheet_Activate event but I get an error ..
Elton PascuaCommented:
That code can be called once. Did you want to control "tabbing" on a specific range?
Massimo ScolaAuthor Commented:
yes, the range is called "Orders"
and I'd use the same "tabbing" on another range called "Customers" with another userform/macro
Massimo ScolaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.