focus?

C

Chrome

hi, i have a 6 text boxes which i only allow number to be entered. Bu
how can i make it so that when the user clicks accept, and a textbo
has a value higher than 16 or lower than 0, that box is selected; ha
focus?

here is what i have:

If Val(Sheet3.txtU1) > 16 Or Val(Sheet3.txtU1) < 0 Then
MsgBox "Please enter a number between 0 and 16 for Unit 1."
vbOKOnly, "Invalid Value"
Sheet3.txtU2.SetFocus
End If

but set focus dosn't work. thanks for any help
 
G

Guest

Use Activate not SetFocu
Sheet3.txtU2.Activate
----- Chrome > wrote: ----

hi, i have a 6 text boxes which i only allow number to be entered. Bu
how can i make it so that when the user clicks accept, and a textbo
has a value higher than 16 or lower than 0, that box is selected; ha
focus

here is what i have

If Val(Sheet3.txtU1) > 16 Or Val(Sheet3.txtU1) < 0 The
MsgBox "Please enter a number between 0 and 16 for Unit 1."
vbOKOnly, "Invalid Value
Sheet3.txtU2.SetFocu
End I

but set focus dosn't work. thanks for any help
 
C

Chrome

ok thanks i now have this code:

If Val(Sheet3.txtU1) > 16 Or Val(Sheet3.txtU1) < 0 Then
MsgBox "Please enter a number between 0 and 16 for Unit 1.",
vbOKOnly, "Invalid Value"
Sheet3.txtU1.Activate
Sheet3.txtU1.SelStart = 0
Sheet3.txtU1.SelLength = Len(Sheet3.txtU2)
End If

but it highlights sheet3.txtu1.activate with the error shown in the
attatchment.

Attachment filename: error.jpg
Download attachment: http://www.excelforum.com/attachment.php?postid=543854
 
G

Guest

Works fine for me! Don't know what to tell you! Are you sure thats the valid name for the TextBox

If Val(Sheet3.txtU1) > 16 Or Val(Sheet3.txtU1) < 0 The
MsgBox "Please enter a number between 0 and 16 for Unit 1."
vbOKOnly, "Invalid Value
Sheet3.txtU1.Activat
Sheet3.txtU1.SelStart =
Sheet3.txtU1.SelLength = Len(Sheet3.txtU2
End I

but it highlights sheet3.txtu1.activate with the error shown in th
attatchment

Attachment filename: error.jpg
Download attachment: http://www.excelforum.com/attachment.php?postid=54385
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top