+ Reply to Thread
Results 1 to 12 of 12

cell cannot be blank if a certain value of another cell exists

  1. #1
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    cell cannot be blank if a certain value of another cell exists

    hi,
    I want enforce users to enter a value to column E of Sheet2 if the correspondent row of column B on Sheet1 has a certain value, say "PRESENT".

    So let's say, cell Sheet1.B1 = "PRESENT", then when the users reach to Sheet2.E1, they cannot skip it unless they enter something.
    But if Sheet1.B1 = "" or a different value, then users can tab pass Sheet2.E1 without problem.

    Any help is really appreciated!
    Valkie

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: cell cannot be blank if a certain value of another cell exists

    Is this validation just for 1 cell? Or are there chances of many rows having the similar type of validation?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: cell cannot be blank if a certain value of another cell exists

    Hi and welcome to the Forum.

    One way to do this, is using the Custom Validation.

    In my case i can give you the solution that you need, using one helper cell. Let's say IV1, in sheet 2.

    So in IV1, put the formula. =IF(Tag<>"present";1;0)+IF(AND(Tag="present";E1<>"");1;0) Tag is the Name that a i gave to Sheet1!B1.

    Now in the range that you need to "Lock", use this formula. =COUNTIF($IV$1;1)

    dATA>>vALIDATION>Custom>>..... (In my example, A1:P30>>YELLOW AREA)

    Hope to helps you.
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: cell cannot be blank if a certain value of another cell exists

    Quote Originally Posted by arlu1201 View Post
    Is this validation just for 1 cell? Or are there chances of many rows having the similar type of validation?
    Hi Arlu,
    This validation is for the whole Sheet2!E column, so every row in E column will need this validation.
    So let's say
    Sheet2!E1 will be validated based on the value of Sheet1!B1
    Sheet2!E2 will be validated based on the value of Sheet1!B2

    Thanks!

  5. #5
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: cell cannot be blank if a certain value of another cell exists

    hi Fortis,
    Somehow the spreadsheet does not work for me.
    It seems like the spreadsheet works differently, it prompts me error if I enter a value to Sheet2!E1 when Sheet1!B1 is empty OR having any value different than 'Present'.
    But if Sheet1!B1 has value as 'Present', then it does not prompt me any error whether I enter a value to Sheet2!E1 or not.

    Thank you for your help!
    Valkie

    Quote Originally Posted by Fotis1991 View Post
    Hi and welcome to the Forum.

    One way to do this, is using the Custom Validation.

    In my case i can give you the solution that you need, using one helper cell. Let's say IV1, in sheet 2.

    So in IV1, put the formula. =IF(Tag<>"present";1;0)+IF(AND(Tag="present";E1<>"");1;0) Tag is the Name that a i gave to Sheet1!B1.

    Now in the range that you need to "Lock", use this formula. =COUNTIF($IV$1;1)

    dATA>>vALIDATION>Custom>>..... (In my example, A1:P30>>YELLOW AREA)

    Hope to helps you.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: cell cannot be blank if a certain value of another cell exists

    Hi valkie!

    Are you sure that you checked my attachement well??

    ....it prompts me error if I enter a value to Sheet2!E1 when Sheet1!B1 is empty OR having any value different than 'Present'.
    in my example Sheet1 & Sheet 2. In sHEET 1, b1=empty. In Sheet2>>E1, i put any value. No error. In the range that i have lock, i can put any value, because Sheet1!BI>>>IS NOT "PRESENT"!!

    2ND & 2ND Sheets: Sheet1!b1=something else(not "present". In Sheet2!e1, put any value you like.In the range that i have lock, i can put any value, because Sheet1!BI>>>IS NOT "PRESENT"!!
    Post4
    ....But if Sheet1!B1 has value as 'Present', then it does not prompt me any error whether I enter a value to Sheet2!E1 or not.
    In this case if Sheet1!b1="present" and Sheet2!e1=EMPTY, then you can put no value in range A1:P30.

    Pls let me know!
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: cell cannot be blank if a certain value of another cell exists

    Ah.. I think I got your idea now.
    "In this case if Sheet1!b1="present" and Sheet2!e1=EMPTY, then you can put no value in range A1:P30."
    But what I need is IF Sheet1!B1="present" then users can enter any value (or leave blank) any other cells except for Sheet2!E1, they HAVE TO enter something into Sheet2!E1.

    Thank you, Fortis.
    Valkie

    Quote Originally Posted by Fotis1991 View Post
    Hi valkie!

    Are you sure that you checked my attachement well??



    in my example Sheet1 & Sheet 2. In sHEET 1, b1=empty. In Sheet2>>E1, i put any value. No error. In the range that i have lock, i can put any value, because Sheet1!BI>>>IS NOT "PRESENT"!!

    2ND & 2ND Sheets: Sheet1!b1=something else(not "present". In Sheet2!e1, put any value you like.In the range that i have lock, i can put any value, because Sheet1!BI>>>IS NOT "PRESENT"!!
    Post4


    In this case if Sheet1!b1="present" and Sheet2!e1=EMPTY, then you can put no value in range A1:P30.

    Pls let me know!

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: cell cannot be blank if a certain value of another cell exists

    Hi

    But what I need is IF Sheet1!B1="present" then users can enter any value (or leave blank) any other cells except for Sheet2!E1, they HAVE TO enter something into Sheet2!E1.
    If the user don't type anything in Sheet2!E1;what will happened?

    It's not easy to force a user to type someting...... Sorry....

  9. #9
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: cell cannot be blank if a certain value of another cell exists

    Quote Originally Posted by Fotis1991 View Post
    If the user don't type anything in Sheet2!E1;what will happened?
    The point is to REMIND user that a certain condition has been met, he/she has to enter a value into this cell. Therefore, once they reach this cell, they cannot tab away from it without entering something first. I guess if they intentionally want to leave them blank, they can do it by mouse clicking on another cell(?).

    Thanks, Fortis.
    Valkie

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: cell cannot be blank if a certain value of another cell exists

    Hi Valkie

    Therefore, once they reach this cell, they cannot tab away from it without entering something first
    I do not know the way to do such a thing...

    My idea(solution), is using the validation in a range..,to don't allow the users to type anything, if first don't type something in E1.

    So this is it....

  11. #11
    Registered User
    Join Date
    12-30-2011
    Location
    Reston, VA
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: cell cannot be blank if a certain value of another cell exists

    Thank you very much, Fortis, for all your efforts and time!
    Very much appreciated!

    Valkie

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: cell cannot be blank if a certain value of another cell exists

    You are welcome!

+ 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