+ Reply to Thread
Results 1 to 3 of 3

Highlight values in Userform textbox

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-08-2012
    Location
    englang
    MS-Off Ver
    Excel 2010
    Posts
    152

    Highlight values in Userform textbox

    Hi guys,
    i need help with the textbox "txtOrder" in userform.
    After everything what is listed bellow done i need to highlight the numbers in the textbox "txtOrder", so the user dont have to use the backspace key to clear the numbers in textbox "txtOrder" and can start typing the numbers straight away.
    Thanks for your help

    Private Sub cmdUpdate_Click()
      If Trim(Me.txtQty.Value) = "" Then Exit Sub
      Dim Addto As Range, ctl As Control, ws As Worksheet: Set ws = Sheet2
         
        If Me.Frame3.Visible = True And Me.Frame3.Enabled = True Then
            For Each ctl In Me.Frame3.Controls
                If ctl Then
                    With ws
                        Set Addto = ws.Range("a" & Rows.Count).End(xlUp).Offset(1)
                        Addto.Resize(, 17) = Array(cmbDate.Value, txtTime.Value, cmbOperator, cmbLine.Value, txtOrder.Value, txtPart.Value, txtDescription, txtQty.Value, txtUom, txtSample.Value, cmbMaj.Value, cmbPass, cmbFailr, txtComments, cmbOnline, cmbCode, cmbCoperator)
                        Addto.Offset(, 17) = ctl.Caption
                    End With
                End If
            Next
        Else
            Set Addto = ws.Range("a" & Rows.Count).End(xlUp).Offset(1)
            Addto.Resize(, 17) = Array(cmbDate.Value, txtTime.Value, cmbOperator, cmbLine, txtOrder.Value, txtPart.Value, txtDescription, txtQty.Value, txtUom, txtSample.Value, cmbMaj.Value, cmbPass, cmbFailr, txtComments, cmbOnline, cmbCode, cmbCoperator)
            Addto.Offset(, 17) = Array(cmbStation)
            End If
      
                    txtTime.Value = Format(Time, "Long Time")
                    txtPart.Value = ""
                    txtDescription.Value = ""
                    txtQty.Value = ""
                    txtUom.Value = ""
                    cmbCoperator.Value = ""
                    cmbMaj.Value = ""
                    cmbCode.Value = ""
                    txtCdescription.Value = ""
                    cmbFailr.Value = ""
                    txtComments.Value = ""
                    txtSample.Value = ""
                    cmbStation.Value = ""
                    
    End Sub

  2. #2
    Forum Contributor gsnidow's Avatar
    Join Date
    07-22-2010
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    150

    Re: Highlight values in Userform textbox

    Try adding this...
        Me.txtOrder.SetFocus
        Me.txtOrder.SelStart = 0
        Me.txtOrder.SelLength = Len(Me.txtOrder.Text)
    Greg
    Just a guy trying to make work stuff easier.

  3. #3
    Forum Contributor
    Join Date
    08-08-2012
    Location
    englang
    MS-Off Ver
    Excel 2010
    Posts
    152

    Re: Highlight values in Userform textbox

    Thanks Greg it worked perfectly

+ 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 a ComboBox or TextBox in a Userform
    By Paulo Buchsbaum in forum Tips and Tutorials
    Replies: 0
    Last Post: 11-16-2012, 01:38 PM
  3. [SOLVED] highlight text in userform textbox
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 07:50 PM
  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

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