+ Reply to Thread
Results 1 to 4 of 4

vba excel user form restrict input on user textbox

  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Exclamation vba excel user form restrict input on user textbox

    Hi
    I am creating a user form on excel so that the user is prompted to input values and on clicking 'OK', the program returns a loan schedule of the loan amount and the scheduled payments etc. I have created the user-form and I have managed to connect the each text box (where the user inputs values) to each relevant cell in the workbook by using the formula
    [code]
    Range("D5").Formula = UserForm1.TB1.Value
    [/code
    And changing the cell and textbox name in each case. Now what I wish to do is set conditions on each of the textbox in order to limit what the user is able to input. On entering something incorrect, the user should be prompted by a message box. For example, for one of the textboxes, I want the value entered by the user to be rounded down to the nearest integer value. The value also should be no smaller 5000. How would I go about doing this?

    Any help would be greatly appreciated!
    Thanks in advance!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: vba excel user form restrict input on user textbox

    Have a look at using the textbox's Exit event.

    Something like this perhaps.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: vba excel user form restrict input on user textbox

    This is not a question with a simple answer. There are many things to be considered. Lets start with the "Rounding down" to the nearest integer. There are many ways to do it, one is using the rounding feature in VBA called round down (others could be Int(), Fix(), etc). It will round to the nearest integer.

    Example:
    Please Login or Register  to view this content.
    Now for the smaller than 5000 question. Quickest way would be an if statement.

    Example:
    Please Login or Register  to view this content.
    These example are to get you on the right track.

  4. #4
    Registered User
    Join Date
    03-05-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: vba excel user form restrict input on user textbox

    thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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