+ Reply to Thread
Results 1 to 8 of 8

VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

  1. #1
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    Hello,

    I just started writing vba for userforms for excel. I am stuck on this one however...and would like to know what the code would be?

    I would like the following to be always true for my textbox

    - first 3 characters are alphabets, next 3 characters are numeric, next 1 character is Alphabet, last 3 characters are numeric
    -10 total characters.

    so something like this : SCN000A000

    error message if not match the pattern and if not 10 total characters

    Any help would be appreciated.
    Last edited by honger; 12-11-2013 at 12:18 AM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    Are you trying to require input into this textbox in this format?

    Would you like random input when the userform initializes?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    yeah textbox1 is a required field, i am not quite nderstanding what you mean by random input. I am a noob, very new at this.

    This is the current code i have, i have it so that if nothing or less than 10 characters are typed in it will give error message when clicking command "ok" button. But i would like the restrictions to be expanded to how i described above..

    If Len(TextBox1.Text) < 10 Then
    MsgBox "Please Enter Correct SCN #"
    Exit Sub
    End If

  4. #4
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    Quote Originally Posted by Solus Rankin View Post
    Are you trying to require input into this textbox in this format?

    Would you like random input when the userform initializes?
    I think i get your Qs now....

    Yes the value would have to be typed in this format. 3 letters, followed by 3 numbers, 1 letter, 3 numbers = example SCN234A098

    So it shouldnt be random input..

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    To a UserForm module
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-07-2013
    Location
    NJ
    MS-Off Ver
    2010
    Posts
    91

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    thanks so much for the quick replies guys!!!

    Solus rankin, yours worked like a charm...

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: VBA Code for Textbox: First 3 characters Alphabets next 3 characters numeric

    Glad I could help, and welcome to the forum!

    If you are satisfied with the solution please mark the thread as [SOLVED] using the thread tools at the top.

    And with any thread you can show appreciation to those who have helped you by clicking the * below their post.

+ 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] Sum of numeric values within cells also containing non-numeric characters
    By Mike Brewer in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 04-24-2013, 09:16 AM
  2. Generate unique random alphabets for 35 characters in length
    By promo786 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-13-2011, 11:10 PM
  3. Removing Non-Numeric Characters
    By GlenS in forum Excel General
    Replies: 5
    Last Post: 10-12-2005, 06:05 AM
  4. [SOLVED] Converting numeric characters
    By Demmaus in forum Excel General
    Replies: 2
    Last Post: 07-15-2005, 07:05 PM
  5. [SOLVED] Deleting non numeric characters.
    By CyndyG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2005, 06:06 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