+ Reply to Thread
Results 1 to 10 of 10

Validation list - not null

Hybrid View

  1. #1
    Registered User
    Join Date
    03-24-2006
    Posts
    45

    Validation list - not null

    Hello,

    I have set a cell validation to list referencing a column (i.e., the user has the ability to add new values to that list) but I do not want the user to enter null values (i.e., leave blank) in the cell.

    How do I get around the dynamic list?

    Thanks.

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

    Re: Validation list - not null

    Is the problem that in your list you have blank values or just that Excel lets users enter blanks in your DV cell?

    If the second, in the data validation window, uncheck "Ignore blanks"
    If the initial, use a dynamic range so you don't need to include blanks at the end of it.
    Does that help?
    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 dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Validation list - not null

    Hi m.cain,

    You can trace null values by using formula CountBlank
    but I guess range should be known to apply the logic.. could you share the sample workbook... thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  4. #4
    Registered User
    Join Date
    03-24-2006
    Posts
    45

    Re: Validation list - not null

    Hello,

    Lets assume 2 worksheets.

    In the first is a column/field containing a basic list. The user may add to this list or remove from this list. Blanks inevitably occur for all cells that do not have data entered by the user.

    The 2nd sheet contains a cell with a validation list set. The user can select from a drop down list in the cell any of the values that appear in the previous sheet's column.

    I do not want the user to leave that cell blank though.

    Originally we'd thought of simply using some basic VBA code to check when all was done whether that cell was left blank (i.e., "") and if so then it returned a message asking the user to input a value. This didn't work though as it didn't recognize when the user did select a value from the list (i.e., it still assumed it was blank) and would only recognize when the user physically typed in a value. Basically not good.

    Using the Validation would be so much easier. However since the list is based on an open ended column it ignores the "ignore blank" function entirely (i.e, turning that option off doesn't affect nulls).

    If there was say an IF statement that I could use that said something like =IF(A1<>"", ListField, "") then maybe that option might work, but unfortunately "" is not a list itself so it doesn't like that.

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

    Re: Validation list - not null

    1. Not sure what other calculations you have on your sheet but you can incorporate a check in the formula on that cell before doing the calculation.
    For example, if your data val cell is A1, and you have calculation column of the form =VLOOKUP($A$1, Range,2,FALSE), you can change that to
    =IF($A$1<>0, VLOOKUP($A$1,Range,2,FALSE),"A value must be entered into A1") Do this on all formulas on the sheet.

    2. You can use VBA to check on that DV cell whenever a manual entry is performed or prior to saving or printing. Depending on how complex your formulas are, this might be the best option.

  6. #6
    Registered User
    Join Date
    03-24-2006
    Posts
    45

    Re: Validation list - not null

    Here is a very basic example of the scenario (see attachment). I don't want the user to be able to leave cell B2 blank in the DataSheet. The user can add as many new elements to column A in ListSheet as they want and it must be reflected automatically in the list in the DataSheet drop down.

    As you can see there are no complicated formulas or vlookups involved here.
    Attached Files Attached Files

  7. #7
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Validation list - not null

    EDIT: deleted attachment

    apologies to OP: completely misunderstood requirements...
    Last edited by icestationzbra; 06-27-2012 at 05:03 PM. Reason: sleeping at the wheels...
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  8. #8
    Registered User
    Join Date
    03-24-2006
    Posts
    45

    Re: Validation list - not null

    Thank you for your thoughts, however this still allows the cell to be blank. The whole purpose is to not allow blanks.

    I would also need to copy said helper column formulas down X number of cells (if copied to full column length, there will be a significant lag time I would expect, not to mention a jump in file size, no?) and then hide that column from the user. Some maintenance would also be required if the user started adding or deleting records in that sheet I would expect.

  9. #9
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Validation list - not null

    here is a rudimentary macro to let users know that they need to enter a value in cell D2, if they have navigated to it and then navigated away without selecting a value.

    you could get better solutions if you posted this question in the Programming section.
    Last edited by icestationzbra; 06-30-2012 at 09:21 PM. Reason: updated understanding

  10. #10
    Registered User
    Join Date
    03-24-2006
    Posts
    45

    Re: Validation list - not null

    Indeed. As I mentioned earlier I did previously use VBA to prompt the user to enter a value, except that the VBA would not recognize that a value had been entered if selected from the drop down list.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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