With userforms, when a textbox is activated, the entire contents are automatically highlighted (note that when activating the textbox with a mouse click, if you click on the left-hand side of the textbox, all text will be highlighted, but if you click elsewhere in the textbox, you will enter the textbox where clicked without highlighting any text).
Also, the 'GotFocus' event is triggered as an 'Enter' event in userforms.
' The following is a 'Userform_Initialize' event that highlights all text in textbox1 upon loading the form :
Private Sub Userform_Initialize()
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1)
End Sub
' The following is a 'LostFocus' event that checks if the textbox is empty, and if so, replaces the empty textbox value with the words 'Enter value.' :
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox1.Value = "" Then TextBox1.Value = "Enter Value."
End Sub
' The syntax to get the focus onto a textbox would be:
Textbox1.SetFocus
MP