Tab Function for textboxes on Worksheet not UserForm

L

LRay67

I am trying to set a tab order for a area of textboxes that are directly on a
worksheet, not the UserForm. Anyone know how to do this?

I am not savvy enough to figure it out.

Any help is greatly appreciated. Thanks

Linda
 
R

Rick Rothstein \(MVP - VB\)

You can do this by "cheating" a little bit. First off, you will have to use
an ActiveX text boxes from the Visual Basic toolbar. In the Properties box,
set the TabKeyBehavior property for **each** TextBox to True. Next, use the
KeyPress event check for the Tab key and, if pressed, cancel it and activate
the next TextBox that you want to have focus. Here is the KeyPress event for
TextBox1 which sets focus to TextBox2 if the Tab key is pressed...

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = vbKeyTab Then
KeyAscii = 0
TextBox2.Activate
End If
End Sub

You will need to use the exact same code (except for the name of the TextBox
to activate) in each TextBox's KeyPress event.

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top