How do I tabulate between textbox controls in EXCEL?

J

JGI

In pure Visual Basic it is possible to use the tab key to
pass between textbox controls, however I have not found a
way of doing this in Excel's Visual Basic editor. Any
ideas would be welcome. Thank you.
 
B

Bob Phillips

Is this on a userform. If so, there is a TabIndex property that allows you
to set the tab order.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

JGI

These are textbox controls placed directly onto an Excel 97 worksheet. They have no TabIndex property !

----- Bob Phillips wrote: -----

Is this on a userform. If so, there is a TabIndex property that allows you
to set the tab order.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Bob Phillips

If they are control toolbox controls, this code will work for them.

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim bBackwards As Boolean

Select Case KeyCode
''' These are the only keys we care about.
Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp
Application.ScreenUpdating = False
''' Determine if we need to move backwards.
bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp)
''' In Excel 97 must select cell before activating another
control.
If Application.Version < 9 Then Sheet1.Range("A1").Select
''' Activate the appropriate control based on key(s) pressed.
If bBackwards Then
TextBox3.Activate
Else
TextBox2.Activate
End If
Application.ScreenUpdating = True
End Select
End Sub


add similar code for each control.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

JGI said:
These are textbox controls placed directly onto an Excel 97 worksheet.
They have no TabIndex property !
 
Top