Use the following macro to highlight the saved content of a text field. For this task, you need a UserForm with a text box and a button. In the development environment, double-click the button and insert the following code:
Private Sub CommandButton1_Click()
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
End Sub
Use the SetFocus method to place the mouse pointer on the text field. With the SelStart property, you determine the starting position of the text to be highlighted. The SelLength property defines the number of characters to highlight. Assign the Len function to this property, which determines the total number of characters entered in the text field.