+ Reply to Thread
Results 1 to 2 of 2

highlight textbox when selected

Hybrid View

  1. #1
    Registered User
    Join Date
    04-14-2011
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    39

    highlight textbox when selected

    Hi,

    what is the VBA code for highlighting the textbox when selected?

    I want to have system highlight the textbox when user is inputing the information in that textbox

    textbox_gotfocus()?

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: highlight textbox when selected

    If it's a worksheet textbox :-

    Private Sub TextBox1_GotFocus()
        TextBox1.BackColor = &HC0FFC0
    End Sub
    Private Sub TextBox1_LostFocus()
         TextBox1.BackColor = &HFFFFFF
    End Sub
    If it's a userform :-

    Private Sub TextBox1_Enter()
        TextBox1.BackColor = &HC0FFC0
    End Sub
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        TextBox1.BackColor = &HFFFFFF
    End Sub
    Last edited by AndyLitch; 02-10-2014 at 07:38 PM.
    Elegant Simplicity............. Not Always

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Highlight Row from TextBox in Userform
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2013, 05:07 PM
  2. Highlight text within a textbox
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-07-2009, 02:30 PM
  3. [SOLVED] Highlight the contain of textbox and radio button
    By Peter Cheang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2006, 11:55 AM
  4. [SOLVED] highlight text in userform textbox
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2005, 06:17 PM
  5. Highlight all Text in a Textbox when the textbox is selected
    By RPIJG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2005, 03:28 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1