Change Event of Textbox Was Not Firing on Second Userform

zzws524

New Member
Joined
Jun 8, 2015
Messages
6
[FONT=Tahoma, Microsoft Yahei, Simsun]I created 2 userforms. Each userform has a text box. When the last letter of textbox is “E", close current userform, and open another one. [/FONT]

However, when second userform is loaded, the change event was not working.

Can anybody tell me why or how to fix it? Thanks in advance.


Code for textbox on 1st userform:

Code:
[FONT=Trebuchet MS]Private Sub TextBox1_Change()[/FONT]
[I][FONT=Trebuchet MS]If (Right(UserForm1.TextBox1, 1) = "E") Then[/FONT]
[I][FONT=Trebuchet MS]Unload Me[/FONT]
[I][FONT=Trebuchet MS]Load UserForm2[/FONT]
[I][FONT=Trebuchet MS]UserForm2.Show[/FONT]
[I][FONT=Trebuchet MS]End If[/FONT]
[I][FONT=Trebuchet MS]End Sub[/FONT]

Code for texitbox on 2nd form. It' similar to 1st form.

Code:
[I][FONT=Trebuchet MS]Private Sub TextBox1_Change()[/FONT]
[I][FONT=Trebuchet MS]If (Right(UserForm2.TextBox1, 1) = "E") Then[/FONT]
[I][FONT=Trebuchet MS]Unload Me[/FONT]
[I][FONT=Trebuchet MS]Load UserForm1[/FONT]
[I][FONT=Trebuchet MS]UserForm1.Show[/FONT]
[I][FONT=Trebuchet MS]End If[/FONT]
[I][FONT=Trebuchet MS]End Sub[/FONT][/I][/I][/I][/I][/I][/I][/I]
[/I][/I][/I][/I][/I][/I]
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,215,679
Messages
6,126,181
Members
449,296
Latest member
tinneytwin

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