+ Reply to Thread
Results 1 to 8 of 8

Data validation - intgers bigger than 0 and empty cell not allowed

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Data validation - intgers bigger than 0 and empty cell not allowed

    Hello Everyone,

    Here is my problem. I would like to validate data in cell using data validation so that it content has to be an integer bigger than 0 and cannot be an empty cell. I've tried to use option "whole numbers" but then if I leave the cell empty there is no message that data is invalid. If I use option "nonstandard" and type =AND(A1>=0;A1<>"") I don't know how to include that is has to be an integer. I've tried to find functions like INT, INTEGER or ISINTEGER but it seems that there aren't any of those.

    Could you please help me with my problem? I would be very grateful

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    Whole numbers greater than 0 will do what you are asking for (remove the checkmark next to "ignore blank" also),
    HOWEVER,
    data validation only works when you are entering something into a cell. It won't register that there is no value there. With the "ignore blank" checkmark removed, if you had a number and then erased it, you would get a warning error because you are changing what is in the cell.
    The only way to check to see if the cell is still blank at some point (i.e. before closing or switching to a different spreadsheet) is to use VBA.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    Data validation won't work to prevent an empty cell.

    You could use validation to allow only whole numbers greater than 0 and maybe put a formula in an adjacent cell with a message that clears once a valid entry is made in the other cell.

    To apply validation for whole numbers >0...

    Data Validation
    Allow: Custom
    Formula: =AND(A1>0,INT(A1)=A1)

    Use the appropriate cell reference.

    You could put a formula like this in cell B1:

    =IF(AND(A1>0,INT(N(A1))=A1),"","Enter a whole number >0 in cell A1")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    05-23-2013
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    I've tried that. Initially I have zeros in the cells, than I apply data validation to those cells using option "whole numbers" and settings "bigger or equal to 0" and I uncheck ignore blank. Hit OK, and then if I delete one of those zeros nothing happens. There is no message. But if I try to enter there negative numbers, real numebrs or text there is a message. It looks like Excel treats "0" and "" as it is the same.

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    You initially said it had to be an integer greater than 0, not greater than or equal to. You are right, Excel won't differentiate in this case.

    You can go with custom and
    =AND(A1>=0,INT(A1)=A1, ISNUMBER(A1))

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    Quote Originally Posted by ChemistB View Post
    =AND(A1>=0,INT(A1)=A1, ISNUMBER(A1))
    I don't think you need the test for ISNUMBER.

    In my testing this still doesn't prevent an empty cell.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    Ahhh, I was removing the 0 by backspacing, that brings up the data val but still allows you to delete or "clear contents" Bummer

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Data validation - intgers bigger than 0 and empty cell not allowed

    Yeah, if a user is dead set on leaving a cell empty there's not much you can do to stop them.

+ 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