UserForm Control Question

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
 
R

Rick Rothstein

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
 

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