ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tab Function for textboxes on Worksheet not UserForm (https://www.excelbanter.com/excel-programming/407489-tab-function-textboxes-worksheet-not-userform.html)

LRay67

Tab Function for textboxes on Worksheet not UserForm
 
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

Rick Rothstein \(MVP - VB\)[_1419_]

Tab Function for textboxes on Worksheet not UserForm
 
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


"LRay67" wrote in message
...
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




All times are GMT +1. The time now is 06:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com