Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Highlighting Text In Userform Textbox

  1. #1
    Join Date
    4th November 2005
    Location
    Hertfordshire, UK
    Posts
    224

    Highlighting Text In Userform Textbox

    Hi Guys,

    I have a couple of textboxes on a userform and I want the text to automatically highlight for a certain selection when the user clicks into them.

    I have found a few examples where the text can be selected either when the form is loaded or by clicking a command button but this isn't quite what I need.

    I presume it will be a manipulation of the '.selstart' and '.sellength' properties in an 'Enter' event on the textbox, but I can't quite get it to work myself

    Any help always appreciated.

    Thanks,
    Ian
    Last edited by IanDunnett; October 9th, 2006 at 17:35.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,314

    Re: Highlighting Text In Userform Textbox

    Create a userform with a textbox and commandbutton.
    This should highlight the word test. Use tab key to move between controls.
    VB:
    Private Sub TextBox1_Enter() 
         
        Dim lngPos As Long 
         
        lngPos = InStr(TextBox1.Text, "test") 
        If lngPos > 0 Then 
            TextBox1.SelStart = lngPos - 1 
            TextBox1.SelLength = Len("test") 
        End If 
         
    End Sub 
    Private Sub UserForm_Initialize() 
         
        TextBox1.Text = "This is a test of highlighting" 
        TextBox1.EnterFieldBehavior = fmEnterFieldBehaviorRecallSelection 
         
    End Sub 
    
    

    Cheers
    Andy


  3. #3
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Highlighting Text In Userform Textbox

    Ian

    What do you actually want to do?

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Add Text To UserForm TextBox
    By radioflyer54 in forum EXCEL HELP
    Replies: 2
    Last Post: May 29th, 2008, 00:20
  2. Pass Cell Value To UserForm TextBox As Text
    By jcab in forum EXCEL HELP
    Replies: 3
    Last Post: April 4th, 2008, 07:14
  3. Enter UserForm TextBox Text Into Cell
    By EricJ in forum EXCEL HELP
    Replies: 3
    Last Post: March 19th, 2008, 06:58
  4. Text in UserForm TextBox not Showing
    By 4508Ginx in forum EXCEL HELP
    Replies: 5
    Last Post: June 27th, 2005, 09:30
  5. highlighting a line in a textbox
    By kevin562 in forum EXCEL HELP
    Replies: 4
    Last Post: September 1st, 2004, 08:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno