UserForm Control Question

  • Thread starter Thread starter Mark Knutson
  • Start date Start date
M

Mark Knutson

I have fifteen text boxes in my userform. They have a default value of
zero. When my form loads, the first text box has the focus. I want to
highlight or select the zero so when I enter a number into the text box
it will overwrite the zero rather then put the number after the zero. I
can't figure out the code I need to highlight the zero.

The following text boxes highlight the zero automatically when I press
enter in the previous text boxes. So I just need to be able select the
first text boxes zero. Any help will be appreciated. Thanks in advance.
By the way I have excel 2003. Thanks, Mark
 
This UserForm Initialize event code should do what you want...

Private Sub UserForm_Initialize()
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
 
Back
Top