TextBox Issue

zyhin

Board Regular
Joined
Oct 8, 2009
Messages
78
Hi all,

I have a userform with 2 text boxes, one is limited to 4 numbers and the other 2. Is there anyway to get the text box to automatically goto the second text box once you put you first 4 numbers in. I would like this to work like most progams when you enter serial codes.

Thank

Z
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Let's assume your text boxes are called TextBox1 and TextBox2. Right-click TextBox1 in design mode and select View Code. From the two dropdowns select TextBox1 and Change.

VBA will provide the lines in blue - you just add the line in red:-
Code:
[COLOR=blue]Private Sub TextBox1_Change()[/COLOR]
 
[COLOR=red]  If Len(TextBox1) = 4 Then TextBox2.SetFocus[/COLOR]
 
[COLOR=blue]End Sub[/COLOR]
If your text boxes aren't called TextBox1 and TextBox2, modify the code accordingly.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,551
Members
452,927
Latest member
rows and columns

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