+ Reply to Thread
Results 1 to 7 of 7

Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blank)

  1. #1
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blank)

    I'm trying to use the following code to prevent my users from leaving cell (D3) blank.

    Please Login or Register  to view this content.
    The cell is contained in a protected worksheet. The contents of the drop down list are contained in a hidden worksheet that I'm using for data validation purposes. Let's say the list on the separate worksheet is as follows:

    '
    Dog
    Cat

    The " ' " is used so the cell appears blank until the user clicks on the cell and selects an option. I need the blank option since both options (i.e. Dog or Cat) are programmed to auto populate other cells with specific data.

    The above code works great in cells that do NOT contain a drop down list. Any ideas how to modify it to suit my need? Thanks.

    Matthew

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    If D3 contains "'" by default, then it is not Empty.

    Maybe change this...
    If IsEmpty([D3]) Then

    To this...
    If Len([D3]) = 0 Then
    Last edited by AlphaFrog; 04-14-2014 at 10:09 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    AlphaFrog,

    Thanks. That works great. I placed the following code in the same worksheet as D3. The only issues now I'm having are:

    Please Login or Register  to view this content.
    1) Since I've coded D3 to be the first field highlighted when the workbook opens and D3 is blank upon open, the warning message pops up automatically when the workbook loads. Is there a way to prevent this but to allow it if the user attempts to leave D3 without first selecting an option from the drop down list?

    2) The user is required to click the "OK" button twice to close the warning message. Thoughts?

    Other than that, perfect solution. Thanks.

    Matthew

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    AlphaFrog,

    Thanks again. I placed the code in my "working form" (form I use to test out code) and it works great. I then applied the code to another workbook and I'm still getting the two issues I indicated in post #3. I believe I have competing or redundant codes at work. I've attached the two workbooks that contain the code I'm trying to use. The HCT-RCS ITP project is the form where the code is glitchy. The password for the workbook, worksheets and VBA code is "j". In both workbooks I placed the code in worksheet1. Thanks.

    If this gets super complicated I'll just back the code out of the form and go at it from another angle. Thanks again for taking a look.

    Matthew
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    In HTC....xlsm, D3 is merged with cell E3. Cannot select one cell without the other.

    If Target.Address <> "$D$3:$E$3" Then


    I didn't check the other file. I assume the problem is similar.

  7. #7
    Forum Contributor
    Join Date
    02-22-2014
    Location
    Winthrop, ME
    MS-Off Ver
    Excel 2010
    Posts
    420

    Re: Force data entry in cell with drop down list (i.e. Prevent user from leaving cell blan

    AlphaFrog,

    That makes perfect sense. Thank you for steering me in the correct direction. The other file works perfectly since no cells are merged. Thanks.

    Matthew

+ 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. excel stalls when leaving cell after data entry
    By bobmayers in forum Excel General
    Replies: 1
    Last Post: 01-31-2014, 05:39 PM
  2. Force a user to carry out a task after entry into a specific cell
    By wileydogdan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-27-2012, 12:40 PM
  3. Force user to make entry into column T when leaving that record
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-15-2012, 11:00 PM
  4. Replies: 2
    Last Post: 07-28-2011, 07:00 AM
  5. [SOLVED] prevent a user leaving a blank cell in excel2003
    By Ian Varty in forum Excel General
    Replies: 1
    Last Post: 04-15-2005, 09:06 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