+ Reply to Thread
Results 1 to 7 of 7

Restrict text entry in textbox to JUST TEXT

  1. #1
    Forum Contributor
    Join Date
    06-01-2009
    Location
    Cincinatti,Ohio
    MS-Off Ver
    Excel 2003
    Posts
    122

    Restrict text entry in textbox to JUST TEXT

    I have a text box that I am using as the "search target" and to add to the database sheet. I need a way to make sure the user does not enter any spaces or funny characters that would make it more difficult to find the match when they want to search the database sheet at a later date.
    For example if the user types in:

    TEST123
    it will get added to the database,

    Then when they are trying to search the database they might accedentaly type in:
    TEST 123

    The SPACE will cause the database search macro to not find a match.
    The search macro is not case sensitive, but is sensitive to any spaces..
    Plus I think it will be easier for them to remember if it has to be ONLY Text and NO SPACES.
    I Hope this makes sense, please ask if you need more clarification.
    Thank you for your time,
    Last edited by TheNewGuy; 07-24-2009 at 03:54 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Restrict text entry in textbox to JUST TEXT

    So you want to ensure no spaces or funny characters are allowed?

    Define "funny characters".

  3. #3
    Forum Contributor
    Join Date
    06-01-2009
    Location
    Cincinatti,Ohio
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: Restrict text entry in textbox to JUST TEXT

    Sorry,
    "Funny Characters"= .,;;''!@#$%^&*(){[}]-_/?><.....stuff like that..

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Restrict text entry in textbox to JUST TEXT

    Here's a little UserDefinedFunction you can use as is in your code to run your textbox entry through, it will strip out all characters not alphabetic.

    Or you can use the technique it shows directly within your own code.
    Please Login or Register  to view this content.
    When I put that into a textbox_change code, it seems to disallow anything except alphabet characters right from the user interface, very nice.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-24-2009 at 12:19 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Restrict text entry in textbox to JUST TEXT

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-01-2009
    Location
    Cincinatti,Ohio
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: Restrict text entry in textbox to JUST TEXT

    I am not sure that is working, I tried it and it does not seem to do anything.
    I was going to make my own userfrom to function as a error msg. Your code does not need me to Correct? And It is supposed to go into the Textbox1_change Correct? How is it supposed to work?

  7. #7
    Forum Contributor
    Join Date
    06-01-2009
    Location
    Cincinatti,Ohio
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: Restrict text entry in textbox to JUST TEXT

    Sorry, I'm an idiot. Your code works perfectly! Thank you very much for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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