+ Reply to Thread
Results 1 to 5 of 5

Data Validation in textbox on userform

  1. #1
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Data Validation in textbox on userform

    Hi, I have a userform where a user can enter a postcode in the textbox on the userform, and so the post code is entered in the table once the user clicks OK on the userform. I am just wondering is there a VBA code which can limit the user to only entering 2 characters for the post code, and if he/she enters more than two characters and clicks on OK on the uerform, then a message box pop ups warning that only two characters are allowed.

    I am guessing a If statement is needed, yet because I am new to VBA coding I am not quite sure how to construct it. Can anyone please help me?
    Last edited by nav505; 03-12-2013 at 06:35 PM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Data Validation in textbox on userform

    ActiveX textboxes on a userform have a MAXLENGTH property - just set it to 2.

  3. #3
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Data Validation in textbox on userform

    How do I add an activeX textBox on a userform in Visual Basic Editor

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Data Validation in textbox on userform

    a userform ...enter a postcode in the textbox
    It seems you already have. ActiveX controls are the only type that can be added to a userform. Click on the textbox, click F4 to view the properties window and look for MAXLENGTH (The properties are listed alphabetically).

  5. #5
    Forum Contributor
    Join Date
    02-10-2013
    Location
    Wolverhampton
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: Data Validation in textbox on userform

    Oh, thanks for the help, much appreciated

+ 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