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

Posted on 2012-08-20
Last Modified: 2012-08-29

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

Question by:mscola
    LVL 8

    Accepted Solution

    You can substitute myMacro with the actual sub procedure name.

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

    Open in new window


    Author Comment

    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 ..
    LVL 8

    Expert Comment

    by:Elton Pascua
    That code can be called once. Did you want to control "tabbing" on a specific range?

    Author Comment

    yes, the range is called "Orders"
    and I'd use the same "tabbing" on another range called "Customers" with another userform/macro

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
    This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
    Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
    Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now