AllExperts > Excel 
Search      
Excel
Volunteer
Answers to thousands of questions
 Home · More Excel Questions · Answer Library  · Encyclopedia ·
More Excel Answers
Question Library

Ask a question about Excel
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Jan Karel Pieterse
Expertise
Excel and Excel/VBA questions

Experience
Excel MVP

Organizations
Self employed Excel developer

Education/Credentials
Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...

 
   

You are here:  Experts > Computing/Technology > Microsoft Software > Excel > visual basic help

Excel - visual basic help


Expert: Jan Karel Pieterse - 11/7/2009

Question
assume that the insertion point is positioned at the beginning of the txtName text box. which one of following instructions will select the contents of the txtName text box?
txtName.SelAll=txtName.Text
txtName.SelLen=Length[txtName.Text]
txtName.SelLength=txtName.Text
txtName.SelLength=Len[txtName.Text]
thanks

Answer
Hi Shawn,

You do need to specify the SelStart too, so this should do the trick:

   txtName.SelStart = 0
   txtName.SelLength = Len(txtName.Text)

If you use a button to invoke this, you can set the focus back to the textbox like this:
   txtName.SetFocus


Add to this Answer   Ask a Question


 
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.