ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlighting Textbox (https://www.excelbanter.com/excel-programming/279161-highlighting-textbox.html)

Garry Jones

Highlighting Textbox
 
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

Chip Pearson

Highlighting Textbox
 
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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com

"Garry Jones" wrote in message
...
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





All times are GMT +1. The time now is 11:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com