Tabbing between Text Boxes on an Excel worksheet

conder

New Member
Joined
Sep 28, 2004
Messages
32
I have text boxes on an Excel workbox but don't seem to be able to tab between them - any ideas?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Odd, have you tried a blank sheet and creating three text boxes - highlight one and press tab, does this work?
 
Upvote 0
You mean from the control toolbox as opposed to text boxes from the Drawing toolbar?

Should still be able to tab, I presume your tab button works. Have you looked at TabKeyBehavior at all?
 
Upvote 0
Hi There - here is a way to do this. the only issue with this code is , depending on the number of textboxes it could be a bit of coding.

Code:
Private Sub txtPath_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Or KeyCode = vbKeyReturn Then
If CBool(Shift And 1) Then
txtPath.Activate
Else
txtMngField.Activate
End If
End If
End Sub

uses textbox from the control toolbox

this will need to be coded for each textbox (like i said could be alot of coding - but it works).

hope this helps

dan
 
Upvote 0
One way...this will handle 3 TextBoxes, modify or add to suit.

Right click on your sheet tab, left click on View Code, and paste the following procedure into the large white area that is the worksheet module. Press Alt+Q to return to the worksheet.


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

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

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then TextBox1.Activate
End Sub
 
Upvote 0
Mr. Urtis,

Thank you so much for your post. It was very helpful. I entered your code and saved the file. At that time the tabbing worked. Unfortunately, when I return to the file the tabbing features are no longer working. Is there something else I should do?

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top