ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   A question about textboxes (https://www.excelbanter.com/excel-programming/312194-question-about-textboxes.html)

abxy[_70_]

A question about textboxes
 

Hi all,

in the userforms i've created, I've always had a user put data into
textbox and then click a command button to do whatever the comman
button does.

However, In the userform that i'm creating right now, i'd like for th
user to put data into the textbox and just press enter and have m
operations carried out instead of having to click a command button. Ho
can this be done?

thanks for the help :

--
abx
-----------------------------------------------------------------------
abxy's Profile: http://www.excelforum.com/member.php...nfo&userid=473
View this thread: http://www.excelforum.com/showthread.php?threadid=26554


kkknie[_200_]

A question about textboxes
 

You can use the keydown event to check for an enter.

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer)
MsgBox KeyCode
If KeyCode = 13 Then
'Your code here
End If
End Sub

You may also want to check for a Tab (KeyCode=9) if they would ever ta
out. Also might need to use TextBox1_Exit event if they mouse out.



--
kkkni
-----------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754
View this thread: http://www.excelforum.com/showthread.php?threadid=26554



All times are GMT +1. The time now is 11:39 PM.

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