![]() |
VBA - Help with Code (see message)
I have written the following code to protect against a formula error i the end user does not enter a number in the textboxes. Private Sub TextBox40_AfterUpdate() If TextBox40 = "" And Not IsNumeric(TextBox40) Then MsgBox "Number Expected Here" TextBox40.Text = "" End If The problem is that everytime I hit tab or enter the MsgBox fires an the cursor jumps to the next textbox in the tab order. What I want t happen is the MsgBox only display is a nonnumeric entry was made an then clear the textbox but remain in it for a new entry. Any suggestions?? Maybe someone could tell me the code to have th cursor stay in TextBox40 if the entry is not numeric. Thanks -- bforster ----------------------------------------------------------------------- bforster1's Profile: http://www.excelforum.com/member.php...fo&userid=1177 View this thread: http://www.excelforum.com/showthread.php?threadid=27583 |
VBA - Help with Code (see message)
did you try TextBox.SetFocus...? for example: Private Sub TextBox40_AfterUpdate() If TextBox40 = "" And Not IsNumeric(TextBox40) Then MsgBox "Number Expected Here" TextBox40.Text = "" TextBox40.SetFocus End If - Manges -- mangesh_yada ----------------------------------------------------------------------- mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047 View this thread: http://www.excelforum.com/showthread.php?threadid=27583 |
All times are GMT +1. The time now is 11:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com