Userform textbox code to run after max length value is reached

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I have a userform with Textbox 1-7
Each TextBox has a max length of 2 set & auto tab is also applied.

I am trying to run a code for when the 2 values are entered in textbox7 but it runs as soon as i enter 1 value

Example of what should happen
Enter two values in textbox1
Now textbox2 is selected
I enter the 2 values again
The code continues
When i reach textbox7 i wish to enter 2 value THEN the code should run BUT not until 2 values have been entered

Code in use

Rich (BB code):
Private Sub TextBox7_Change()
If TextBox7.Value <> 2 Then
Call TransferValues_Click
End If
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Private Sub TextBox7_Change()
If Len(TextBox7) <> TextBox7.MaxLength Then Exit Sub
Call TransferValues_Click
End Sub
 
Upvote 0
oops forgot to enter code correctly
Code:
Private Sub TextBox7_Change()
If Len(TextBox7) <> TextBox7.MaxLength Then Exit Sub
Call TransferValues_Click
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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