Auto enter when 3 digits in a text box

stuartchaffey

New Member
Joined
Dec 28, 2021
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hey,

this is probably so simple but i can not get my head round it.

I want enter to initiate when textbox1 has 3 digits in it, this is just so i dont have to press enter each time to move to the next textbox.

any help greatly appreciated :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi try
VBA Code:
Private Sub TextBox1_Change()
If Len(TextBox1.Value) = 3 Then TextBox2.SetFocus
End Sub
 
Upvote 0
Solution
I want enter to initiate when textbox1 has 3 digits in it, this is just so i dont have to press enter each time to move to the next textbox.

Appreciate you have a solution but just for future reference you can do what you want without VBA. If you go to the controls properties, set the AutoTab property for your TextBox to True and then enter the character MaxLenght for the control.

Doing this should, once a user has entered the maximum number of characters, automatically move the focus to the next control specified in the tab order.

Hope Helpful

Dave

1698572388655.png
 

Attachments

  • 1698572268928.png
    1698572268928.png
    190.8 KB · Views: 5
Upvote 0
You are very welcome
Thank you for the feedback
Be happy and safe
would be good to read dmt32's solution as well.
Best regards
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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