Highlighting Textbox

G

Garry Jones

I have a userform with a Textbox that starts off with an initial value
read in from a cell.

After taking the user to the textbox I want the value withing it to be
highlighted.

This code does not solve it..

_______________________________________

Private Sub UserForm_Initialize()
TextBox1.Text = Worksheets("blad1").Cells(5, 1)
TextBox1.SetFocus
End Sub
_______________________________________

Any ideas?

Garry Jones
 
C

Chip Pearson

Garry,

If you want to highlight (select) the text in a textbox, use the SelStart
and SelLength properties. E.g.,

With Userform1.TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
 

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