Highlight text in textbox

E

Erik

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
 
B

Bob Phillips

Private Sub Userform_Activate()

With Me.TextBox1

.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
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