ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to use ENTER in a TextBox in Excel 2007 (https://www.excelbanter.com/excel-programming/419078-how-use-enter-textbox-excel-2007-a.html)

Lasse[_2_]

How to use ENTER in a TextBox in Excel 2007
 
Hi

I have created a Userform containing some OptionButtons, a TextBox, a OK and
a Cancel button.
I have created a Click behavior for the OK button where I check for which
OptionButtons a user have chosen or if any text is entered in the TextBox.
I would like to add a behavior for the TextBox where I can press ENTER and
it then runs the same macro as pressing the actual OK button.
At the moment when pressing ENTER in the TextBox it moves the focus to the
next object in the tab order.

Any ideas?

/Lasse

Daniel.C[_2_]

How to use ENTER in a TextBox in Excel 2007
 
Hi,
Use the textbox exit event macro.
Regards.
Daniel

Hi

I have created a Userform containing some OptionButtons, a TextBox, a OK and
a Cancel button.
I have created a Click behavior for the OK button where I check for which
OptionButtons a user have chosen or if any text is entered in the TextBox.
I would like to add a behavior for the TextBox where I can press ENTER and
it then runs the same macro as pressing the actual OK button.
At the moment when pressing ENTER in the TextBox it moves the focus to the
next object in the tab order.

Any ideas?

/Lasse




Harald Staff[_2_]

How to use ENTER in a TextBox in Excel 2007
 
Lasse

Set the OK button's Default property to True and it clicks on Enter.
(Likewise, set Cancel buttons Cancel property to true and it clicks on Esc.)

HTH. Best wishes Harald


"Lasse" wrote in message
...
Hi

I have created a Userform containing some OptionButtons, a TextBox, a OK
and
a Cancel button.
I have created a Click behavior for the OK button where I check for which
OptionButtons a user have chosen or if any text is entered in the TextBox.
I would like to add a behavior for the TextBox where I can press ENTER and
it then runs the same macro as pressing the actual OK button.
At the moment when pressing ENTER in the TextBox it moves the focus to the
next object in the tab order.

Any ideas?

/Lasse




All times are GMT +1. The time now is 07:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com