Saturday, October 3, 2015

How to select the contents of a VBA userform textbox on mouse click

Highlighting the contents of a textbox on mouse click in a user's interface eases data entering. To do so, simply enter the following code under the Userform VBA code:

Private Sub TextBox1_MouseDown(ByVal Button As IntegerByVal Shift As Integer, _
ByVal X As SingleByVal Y As Single)
    With TextBox1
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
End Sub



Created by DoMyExcel.com © | Excel & VBA Consulting | Customized Excel Solutions starting at 29 USD
Services provided to Individuals and Businesses | Free Quote: DoMyExcel@gmail.com

No comments:

Post a Comment