Have Questions? 
help@excelvbaisfun.com
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!

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

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!
LEARN MORE
Copyright © 2024 ExcelVbaIsFun
X

Forgot Password?

Join Us

0
    0
    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