Have Questions? 
Excel Ninja Pro
All Access

May 27, 2019

Highlight Userform Textbox in Excel VBA, Highlight All Text On Mouse Click, Button or Userform Open

[et_pb_section fb_built="1" _builder_version="3.22.7"][et_pb_row _builder_version="3.22.7"][et_pb_column type="4_4" _builder_version="3.22.7"][et_pb_text _builder_version="3.22.7"]

In order to highlight text in a TextBox (other than Tabbing into that field), you can insert a couple helpful snippets of VBA  code that will help you accomplish this easily!

The first line tells VBA to put the cursor at the leftmost (0) character:

Me.TextBox1.SelStart = 0

The next line tells it to select the length of whatever the length of characters you have in that textbox:

Me.TextBox1.SelLength = Len(Me.TextBox1)


Pretty simple, right!?

Check out this video to see more details, including how to apply this to a button or even when the userform opens!


Excel VBA Is Fun

We believe Excel is one of the most versatile programs out there - and learning to program and automate it makes you very valuable!

You can prevent wasted time and errors, speed up tasks and become indispensable to your organization. 

See how our trainees have gotten raises, promotions and bonuses using their Excel Automation skills while building real problem-solving programs in Excel!
Copyright © 2024 ExcelVbaIsFun

Forgot Password?

Join Us

    Your Cart
    Your cart is emptyReturn to Shop
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram