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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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