+ Reply to Thread
Results 1 to 4 of 4

Formatting Excel Userform textbox input into one of two specific formats

Hybrid View

  1. #1
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Formatting Excel Userform textbox input into one of two specific formats

    Hi, serose14,

    maybe try
    Private Sub txtExpressCode_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Select Case Len(txtExpressCode.Text)
      Case 9
        txtExpressCode.Text = Format(txtExpressCode.Text, "84271 ##### ####")
      Case 13
        txtExpressCode.Text = Format(txtExpressCode.Text, "84271 ##### #### ####")
      Case 16, 21
      Case Else
        Cancel = True
        MsgBox "Please enter a 9 or 13 digit number"
    End Select
    End Sub
    where my TextBox is named txtExpressCode.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  2. #2
    Registered User
    Join Date
    07-31-2014
    Location
    Ephrata, PA
    MS-Off Ver
    2007
    Posts
    7

    Re: Formatting Excel Userform textbox input into one of two specific formats

    Works like a champ. Thank you.

+ 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. [SOLVED] Pass Value of combobox selected in Userform as input to textbox of other userform
    By Pradeepg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 10:32 AM
  2. input the value of a Combobox and a textbox to a TEXTBOX directly from a userform
    By Gordonhk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 03:25 PM
  3. [SOLVED] UserForm TextBox formats - Display as Decimal, Read as Percent. Possible?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2013, 11:40 PM
  4. Use textbox input and VLookup to update another textbox on same userform
    By gcoug in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2011, 10:39 AM
  5. [SOLVED] Userform textbox number formats
    By PhilM in forum Excel General
    Replies: 2
    Last Post: 06-07-2006, 06:15 AM

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