Q: use _ENTER event

DJ FastEddy

New Member
Joined
Aug 22, 2006
Messages
8
Hi,

I have a UserForm with some textboxes. I want to enter text in TextBox1 and on <Enter> a subroutine must be activated to fill in all the other textboxes. I have done a test setup how it works but only after I entered through all the TextBoxes they are filled with the data.

This is my test setup. If I got the basics working I'll can figure out the rest what I want to do.

Private Sub TextBox1_Enter()

TextBox2 = TextBox1
TextBox3 = TextBox1
TextBox4 = TextBox1

End Sub

All the TextBoxes are on the same UserFrom. In a later stage these TextBoxes will be filled with data from worksheets.

I anyone can give me a hand with this it's much appreciated.

Thanx

Edwin.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Good morning DJ FastEddy

I personally would be tempted to use the TextBox1_Exit event - then the other textboxes are filled in when you tab, enter or click out of the box. Slight amendment to your supplied code :

Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TextBox2.Value = TextBox1.Value
TextBox3.Value = TextBox1.Value
TextBox4.Value = TextBox1.Value
End Sub

HTH

DominicB

EDIT : BTW, the TextBox1_Enter event is fired when you actually enter the textbox, not when you press enter from the textbox.
 

DJ FastEddy

New Member
Joined
Aug 22, 2006
Messages
8
Thanks Dominic,

That's what I was looking for. I have the English version of an Excel programming guide and it didn't explain clearly the differen between Enter and the use of the button <ENTER>.

It works now as I wanted.

Can you explain what this part in your code means: (ByVal Cancel As MSForms.ReturnBoolean).

Thanks again,

Edwin.
 

Forum statistics

Threads
1,136,507
Messages
5,676,263
Members
419,616
Latest member
quickflip

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
Top