How To Get An Event To Run When I Exit A TextBox
If the textbox is in a userform, then use the Exit event.
In a worksheet, you would have to use one of the key events like KeyDown to
test for keys such as return or tab and perform you action then. Here is
some code Rob Bovey posted which is used to tab between textboxes on a
worksheet, but you can modify it to fit your needs. It too is looking for
the user to finish typing:
Private Sub TextBoxCurrent_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim bBackwards As Boolean
Select Case KeyCode
''' These are the only keys we care about.
Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp
Application.ScreenUpdating = False
''' Determine if we need to move backwards.
bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp)
''' In Excel 97 we must select a cell
''' before activating another control.
If Application.Version < 9 Then Sheet1.Range("A1").Select
''' Activate the appropriate control based on key(s) pressed.
If bBackwards Then TextBoxPrevious.Activate Else _
TextBoxNext.Activate
Application.ScreenUpdating = True
End Select
End Sub
--
Regards,
Tom Ogilvy
"Minitman" wrote in message
...
Greetings,
I need to have a format command to wait until I have finished typing
in a TextBox and when I exit the TextBox for the format to run then.
I have checked the help files for what events are available and could
not find one that would work.
Any one have any suggestions?
TIA
-Minitman
|