A family of Microsoft word processing software products for creating web, email, and print documents.
If you know what text will be in the text box when the userform appears (because your code is creating that text), you can assign a specific number to the text box's .SelStart property. The correct number is the number of characters to the left of the insertion point.
Private Sub UserForm_Initialize()
With TextBox1
.Text = "This is the text when the userform starts."
.SelStart = 12 'before the t in "text"
.SetFocus
End With
End Sub
If you want one or more characters to be selected instead of just an insertion point, also set the .SelLength property's value.
If you don't know what text will be there (for example, you're copying in text from the document body), you can use the InStr function on the box's .Text property to search the string for a particular substring. To put the insertion point at the end of the text, use
.SelStart = Len(.Text)