Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Tom,
I appreciate this reply and all of the assistance you give so freely. This solution is interesting but it goes a lot farther then I need. Check out the other reply, it seems to be a bit more simplified. -Minitman On Fri, 22 Oct 2004 13:07:50 -0400, "Tom Ogilvy" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the textbox is in a userform, then use the Exit event.
Read my suggestion. The first suggestion I made was the exit event (which only works for a userform). This is the same suggestion posted after me by Mr. Datasort. without such qualification or explanation and which you found so helpful. I then offered an alternative approach again, stating clearly that this was if your textbox was not on a userform. Check out the other reply, it seems to be a bit more simplified. Kick me again <LOL -- Regards, Tom Ogilvy "Minitman" wrote in message ... Hey Tom, I appreciate this reply and all of the assistance you give so freely. This solution is interesting but it goes a lot farther then I need. Check out the other reply, it seems to be a bit more simplified. -Minitman On Fri, 22 Oct 2004 13:07:50 -0400, "Tom Ogilvy" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Tom.
I must apologize. I did not understand that "Exit" was the name of the Exit event until I saw the code snippet. My only excuse is my inexperience with VBA and writing code. I did not mean to "Kick" you once or again. Please accept my apology. I find the knowledge and assistance you dispense so unselfishly to be of great value. Please, don't let my ignorant babblings discourage you in the pursuit of educating the unexperienced and uneducated wannabe Excel programmers out here to comprehend the deepest mysteries of Excel. <G -Minitman On Fri, 22 Oct 2004 15:16:24 -0400, "Tom Ogilvy" wrote: If the textbox is in a userform, then use the Exit event. Read my suggestion. The first suggestion I made was the exit event (which only works for a userform). This is the same suggestion posted after me by Mr. Datasort. without such qualification or explanation and which you found so helpful. I then offered an alternative approach again, stating clearly that this was if your textbox was not on a userform. Check out the other reply, it seems to be a bit more simplified. Kick me again <LOL |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I did say
Kick me again <LOL I guess I should have used "<g" to be clearer - it was an attempt at grim humor. No need to apologize. The original poster is always free to make their own decisions. (and I am free to be Sardonic <g) -- Regards, Tom Ogilvy "Minitman" wrote in message ... Hey Tom. I must apologize. I did not understand that "Exit" was the name of the Exit event until I saw the code snippet. My only excuse is my inexperience with VBA and writing code. I did not mean to "Kick" you once or again. Please accept my apology. I find the knowledge and assistance you dispense so unselfishly to be of great value. Please, don't let my ignorant babblings discourage you in the pursuit of educating the unexperienced and uneducated wannabe Excel programmers out here to comprehend the deepest mysteries of Excel. <G -Minitman On Fri, 22 Oct 2004 15:16:24 -0400, "Tom Ogilvy" wrote: If the textbox is in a userform, then use the Exit event. Read my suggestion. The first suggestion I made was the exit event (which only works for a userform). This is the same suggestion posted after me by Mr. Datasort. without such qualification or explanation and which you found so helpful. I then offered an alternative approach again, stating clearly that this was if your textbox was not on a userform. Check out the other reply, it seems to be a bit more simplified. Kick me again <LOL |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the event
Private Sub TBox_NAME_Exit(ByVal Cancel As MSForms.ReturnBoolean) where TBox_NAME is the name of your text box "Minitman" wrote: 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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you
That is just what I was hoping for. -Minitman On Fri, 22 Oct 2004 10:09:06 -0700, "Datasort" wrote: Try the event Private Sub TBox_NAME_Exit(ByVal Cancel As MSForms.ReturnBoolean) where TBox_NAME is the name of your text box "Minitman" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Private Textbox Exit Sub question... | Excel Worksheet Functions | |||
combobox exit event | Excel Programming | |||
Exit Event | Excel Programming | |||
MSForms.TextBox Exit event isn't available in Excel class mosule | Excel Programming | |||
Control Exit event | Excel Programming |