+ Reply to Thread
Results 1 to 5 of 5

Limit Character Length in a Userform Textbox

  1. #1
    Registered User
    Join Date
    12-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Limit Character Length in a Userform Textbox

    In Userform1 I have several textbox and one commandbutton1. If I mouseclick on a textbox and click commandbutton1 the letters YES is entered in the texbox. To prevent double click entry into the same textbox I set the maximum length property at 3. However, setting the maximum length to 3 does not work. Subsequent commandbutton1 clicks will result in an infinite YES entries.

    Is the maximum length property disabled when commandbutton entries are applied?

    Thank you,
    Gal403

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Limit Character Length in a Userform Textbox

    The maxlength only applies when manually typing. If you set the text via code it is ignored.

    Please Login or Register  to view this content.
    You don't show the code you are using but it should look like this.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    12-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Limit Character Length in a Userform Textbox

    SAMPLE 2.xlsm

    Thank you Andy. I'm familiar with the code you suggested. I've attached a sample userform as an example. As you can see, I can enter an infinite combination of fruit in the textbox. My fear is a user can enter multiple entries in any given textbox when I only require the user to enter a single commandbutton click. Using my existing code I'm note sure if a code should be placed in the textbox limiting a single entry; or a code in each command button that will only allow a single click.

    If the user needs to retract the entry then I will need to create a fourth command button that will clear the textbox that has focus.

    Gal

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Limit Character Length in a Userform Textbox

    Please Login or Register  to view this content.
    This change will enter only the buttons associated text, replacing existing text.

    You will require more code if each buttons text can only appear once.

  5. #5
    Registered User
    Join Date
    12-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Limit Character Length in a Userform Textbox

    Andy, that was brilliant! Thank you very much

+ 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] expand textbox character limit in userform
    By tomanton in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-05-2014, 06:04 AM
  2. Limit character type and length in cell possible?
    By Fidd$ in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 07-01-2010, 04:31 AM
  3. limit character length when copying or typing
    By goofy11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-05-2006, 03:10 PM
  4. [SOLVED] limit character in textbox
    By Steph in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2005, 05:05 PM
  5. How do I limit the character length of a cell when typing
    By Andy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2005, 11:05 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