+ Reply to Thread
Results 1 to 7 of 7

[SOLVED] How to determine if the user input a STRING or an INTEGER?

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    [SOLVED] How to determine if the user input a STRING or an INTEGER?

    Is there a way to know if the user input a STRING or an INTEGER?

    Example: 1, 2, 3, 4, 5

    (NO DECIMAL PLACES)

    I have an input box that the user will input a number only and I don't want the user input a string or something that not related to integer data type. I mean I need a validation that will determine the user input a string or something not related to integer.
    Last edited by mcmunoz; 08-26-2013 at 10:39 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: How to determine if the user input a STRING or an INTEGER?

    Hi,

    Try this code (assuming inpt is the name of the variable that the user-entry is saved to):
    Please Login or Register  to view this content.
    Hope this helps

  3. #3
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: How to determine if the user input a STRING or an INTEGER?

    Thank you ajryan for helping me.

    I forgot the power of IsNumeric() . -.-

    But how to deal with decimal number. Like 1.2, 4.9, 0.1 ............ I input decimal still accept >.<

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: How to determine if the user input a STRING or an INTEGER?

    IsNumeric will return a value of TRUE for ANY number - integer or decimal.

    If you want to exclude the user from entering a decimal, then do this check also:
    Please Login or Register  to view this content.
    Hope this helps

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: How to determine if the user input a STRING or an INTEGER?

    Although, this will stop the user entering a perfectly valid value of, say, "1.0". So perhaps use this instead:
    Please Login or Register  to view this content.
    Note that with both of my second solutions here, they need to be checked AFTER you have ensured that the inpt value is numeric.

    Hope this helps

  6. #6
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: How to determine if the user input a STRING or an INTEGER?

    Ohhh. I get it.

    I make a double IF STATMENT for DECIMAL PLACES and for IsNumeric.

    Thanks a lot for the help ajryan All of them work properly.

  7. #7
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: How to determine if the user input a STRING or an INTEGER?

    That's right!

    No problems at all, always happy to help

    Please don't forget to mark this thread as solved and please click on the * next to my posts to say thanks

    Have a great day!

+ 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. user defined macro to replace certain characters in a string based on user input
    By whatappears in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 06:25 PM
  2. Auto Generation of String based on user input
    By dhimbak in forum Excel General
    Replies: 3
    Last Post: 06-04-2009, 09:12 AM
  3. Determine person's age as an integer
    By jamesoc79 in forum Excel General
    Replies: 3
    Last Post: 05-14-2009, 04:22 PM
  4. Validate input of user, Integer required
    By Gabor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2007, 06:45 PM
  5. Determine if Integer is Odd or Even
    By GoFigure in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-13-2005, 11:15 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