ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlight text in textbox (https://www.excelbanter.com/excel-programming/414528-highlight-text-textbox.html)

Erik

Highlight text in textbox
 
When I start my excel workbook I want a userform to pop up with the current
time highlighted in a textbox. I must be able to overwrite that text and copy
that value to a cell in a worksheet. How can I do this?

The point is to record the time a show up for work and put dates and time in
a worksheet.

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub UserForm_Initialize()
TextBox1.Text = WorksheetFunction.Text(Now(), "hh:mm")
TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
End Sub


Bob Phillips[_3_]

Highlight text in textbox
 
Private Sub Userform_Activate()

With Me.TextBox1

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

--
__________________________________
HTH

Bob

"Erik" wrote in message
...
When I start my excel workbook I want a userform to pop up with the
current
time highlighted in a textbox. I must be able to overwrite that text and
copy
that value to a cell in a worksheet. How can I do this?

The point is to record the time a show up for work and put dates and time
in
a worksheet.

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Private Sub UserForm_Initialize()
TextBox1.Text = WorksheetFunction.Text(Now(), "hh:mm")
TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorSelectAll
End Sub




Erik

Highlight text in textbox
 
Thanks!


All times are GMT +1. The time now is 08:59 AM.

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