I have a userform where I have different textboxes. What I want is for the all the contents to be selected upon focus on the box. I am trying to get this to work through Excel VBA.

Googling gave me some inspiration to use selstart and sellength.

The name of the box is txtStartHour, and the name of the sub is "txtStartHour_enter", I figure that "enter" is the VBA eqvivalent of "GotFocus" in VB6.


I have tried
With Me.txtStartHour
.SetFocus
.SelStart = 0
.SelLength = Len(Me.txtStartHour.Text)
End With


and
txtStartHour.setFocus
txtStartHour.SelStart=0
txtStartHour.SelLength=len(txtStartHour.text)

The sub is getting called, I am assured of this as when I go step by step the code get highlighted.

Thanks!