+ Reply to Thread
Results 1 to 2 of 2

Restrict the value entered into a textbox on a userform

  1. #1
    Forum Contributor
    Join Date
    03-14-2013
    Location
    England
    MS-Off Ver
    2007
    Posts
    186

    Restrict the value entered into a textbox on a userform

    Hi,

    I want to use vba to restrict the value entered into a textbox on a userform to a percentage amount, upto 2 decimal places.

    Lets say it's userform1 and textbox1

    Upon entering something into the textbox, if its anything other than a numerical value from 0.00 - 100.00, or to anymore than 2 decimal places... show a message box stating the value entered is not valid and delete what ever was typed into the textbox.

    Please can someone do an example code that would achieve this, it would be helpful for me.

    Many thanks in advance.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Restrict the value entered into a textbox on a userform

    Hi,

    See the file associated with post #2 in the following thread. It does something similar to what you want. It checks a value to make sure it is a number (colors the TextBox red if it is not a number). It also checks to make sure a value is within a certain range (colors the TextBox magenta if the number is not in the proper range): http://www.excelforum.com/excel-prog...ml#post3936074

    Code for the routine you might be interested in follows (in module ModUserForm1 in the file):
    Please Login or Register  to view this content.
    Lewis

+ 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] Restrict Userform Textbox to Numbers Only
    By Mousiefuzz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2015, 04:24 AM
  2. [SOLVED] Search column for entered value and return results to textbox in userform
    By MIFF3436 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2015, 06:35 AM
  3. [SOLVED] show message box when a duplicate entry is entered into a userform textbox
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2012, 05:53 AM
  4. Restrict the date format entered in a cell
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2010, 04:43 PM
  5. restrict textbox on userform to mm/yyyy
    By lcoreilly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2010, 11:40 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