+ Reply to Thread
Results 1 to 10 of 10

Limiting a numerical value to a range but validation is not working

  1. #1
    Registered User
    Join Date
    04-12-2021
    Location
    Singapore
    MS-Off Ver
    Office 365
    Posts
    8

    Question Limiting a numerical value to a range but validation is not working

    Hi I'm creating a userform, which requires a user to provide a value within a specified numerical range depending on the material selected.

    For example, if the material selected is "RIVETED STEEL", the value must be between 0.9144 and 9.144. Otherwise, a message box will appear to remind him that the value is out of range.

    This is the work flow:

    1) In a userform (LeD), user will select a material in a combobox (cbpm)
    2) A window (ARC) will appear to prompt the user to provide a number in a textbox (txtarc).
    3) If the numberis valid, it will be sent to an excel sheet after the user has clicked on a command button (arcadd)
    4) If not, the same message box will reappear to remind user to provide a valid number

    When I provide a valid number, I was still prompted with the message box.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by Wilheim; 06-28-2021 at 08:33 AM.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,161

    Re: Limiting a numerical value to a range but validation is not working

    Remove declaration
    Please Login or Register  to view this content.
    Artik

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Limiting a numerical value to a range but validation is not working

    Keep declaration...Change it to accept decimals...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,161

    Re: Limiting a numerical value to a range but validation is not working

    sintek, we have a name conflict here. We have a txtarc variable and a TextBox named txtarc. In a condition of type
    Please Login or Register  to view this content.
    the variable will be compared, not the value of the control.

    Artik

  5. #5
    Registered User
    Join Date
    04-12-2021
    Location
    Singapore
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Limiting a numerical value to a range but validation is not working

    Hi Artik, I removed the declaration and it works! Thank you so much

  6. #6
    Registered User
    Join Date
    04-12-2021
    Location
    Singapore
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Limiting a numerical value to a range but validation is not working

    Hi sintek, appreciate your help too!

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Limiting a numerical value to a range but validation is not working

    Quote Originally Posted by Artik View Post
    sintek, we have a name conflict here. We have a txtarc variable and a TextBox named txtarc. In a condition of type
    Please Login or Register  to view this content.
    the variable will be compared, not the value of the control.

    Artik
    Oops...Missed that...

  8. #8
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,161

    Re: Limiting a numerical value to a range but validation is not working

    But You'll admit that Wilheim set a nice ambush.

    Artik

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Limiting a numerical value to a range but validation is not working

    Quote Originally Posted by Artik View Post
    But You'll admit that Wilheim set a nice ambush.

    Artik
    I was at fault...Did not read the thread...Just quickly saw his decimals in his If statement and his integer declaration...

  10. #10
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,161

    Re: Limiting a numerical value to a range but validation is not working

    But if Wilheim had taken even more shortcuts by writing this code
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    I would never have guessed the problem.
    Well, maybe I'm exaggerating a bit because you can see that he did not assign a value to the variable txtarc. And the answer would go in that direction.

    Artik

+ 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. Replies: 5
    Last Post: 04-02-2019, 05:53 AM
  2. Replies: 12
    Last Post: 01-27-2016, 03:18 PM
  3. Form validation - Limiting entries
    By stimulus in forum Tips and Tutorials
    Replies: 0
    Last Post: 12-05-2015, 05:14 AM
  4. Limiting Text Length, Without a Data Validation
    By Moho280 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-24-2014, 10:23 AM
  5. Limiting a data validation list
    By brlan4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2013, 12:15 AM
  6. Replies: 0
    Last Post: 10-16-2013, 11:01 AM
  7. Data Validation for limiting user entry
    By geodude57 in forum Excel General
    Replies: 3
    Last Post: 06-25-2012, 05:24 AM

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