+ Reply to Thread
Results 1 to 4 of 4

Formatting Excel Userform textbox input into one of two specific formats

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

    Formatting Excel Userform textbox input into one of two specific formats

    I am new to VBA. I am constructing a VBA userform. I want to restrict input into one of the textboxes to either a 16 or 21 character string with only numerals or spaces (the spaces are to be entered automatically). The first 5 digits are static for both formats, i.e.

    format for 16 digit is "84271 ##### ####"

    format for 21 digit is "84271 ##### #### ####"

    I have created the following code:

    Please Login or Register  to view this content.

    This tests and works correctly for the 21 character input. It is not reading the 16 character format as when I enter 9 numerals, I get the following:

    84271 1 2345 6789

    and my message box appears asking for a 9 or 13 digit input.

    Any help would be appreciated.

    Thank you.
    Last edited by serose14; 08-14-2014 at 01:36 PM.

  2. #2
    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,

    please have a look at Forum Rule #3 and wrap your procedure with code-tags.

    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

  3. #3
    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
    Please Login or Register  to view this content.
    where my TextBox is named txtExpressCode.

    Ciao,
    Holger

  4. #4
    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. 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