none
Excel form with activex textbox

    Question

  •  

    I'm using Excel 2007 and made a form with ActiveX textboxes.  I want to use an arrow or tab key to move from one textbox to another, rather than the cursor.  How can I do this?
    Monday, March 31, 2008 10:22 PM

All replies

  • Assuming the form is done in VBA the following may help (note both are copied straight from Excel VBA help on the relevant topics).

     

    Set the tab order using the Tab Order dialog box

    1. Make sure no controls are selected.
    2. Right-click in the form, but not on a control.
    3. From the shortcut menu, choose Tab Order.
    4. Select the name of a control you want to reposition in the tab order.
    5. Choose Move Up or Move Down until the control name is in the appropriate position in the tab order.

    Set the tab order using the TabIndex property

    1. Identify the tab order you want to use for the form.
      The tab index of the first control in the tab order is 0; the tab index of the second is 1, and so on.
    2. Select a control in the tab order.

    3. In the Properties window, select the TabIndex property.
    4. Enter the appropriate number to identify the control's position in the tab order.
    Friday, April 04, 2008 7:18 AM
  • Hi,

    If the textboxes are actually on a worksheet then you will need to add code to the KeyDown event of each control.

    Code Snippet

    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        
        If KeyCode = vbKeyTab Then
            TextBox2.Activate
        End If
        
    End Sub
    Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        
        If KeyCode = vbKeyTab Then
            TextBox1.Activate
        End If
        
    End Sub



    Friday, April 04, 2008 8:09 AM
  • Is the ActiveX textbox on an Excel userform, or Excel worksheet?  If userform, please explain how to include these controls on a form in Excel.

     

    Thanks...

    Friday, February 27, 2009 11:06 PM