+ Reply to Thread
Results 1 to 14 of 14

Two Data Validation Rules for a Cell based on entry in Adjacent Cell

  1. #1
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    I want to use two different data validation rules for a column of cells (Column C) based on the entry in the column of adjacent cells (Column B).
    In the first case if the adjacent cell in Column B contains a number, the cell in Column C will be limited to inputting a number between 0 and 11 (Yellow highlighted cells).
    In the second case if the adjacent cell in Column B is equal to zero, blank, or not a number, the cell in Column C will be limited to a number between 0 and 9,999,999.
    I am not sure how to set up this to work. Any help would be appreciated.

    I have attached a simple worksheet illustrating this.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    You can't have two different rules but you can combine different conditions into one rule. Use this Custom rule starting in C35:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Implemented in attached file.

    Edit: I did not account for B containing a negative number. Is that a possibility?
    Last edited by 6StringJazzer; 01-21-2021 at 08:52 AM. Reason: corrected reference to starting cell

  3. #3
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Try this formula in Custom rule:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Good luck!
    Last edited by Estevaoba; 01-20-2021 at 11:47 PM.

  4. #4
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    A negative number is not a possibility. Thanks for your reply

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Thank you very much! This custom data validation certainly does the job and accomplishes what I set out to do.

    I am not familiar with the AND statement and how it is used in an IF statement. This senior citizen learns something new every day thanks to people like you.

    I had to break the IF statement down so I would have a better understanding.

    IF Function in Excel

    Syntax: IF(logical_test, value_if_true, [value_if_false])

    Custom Data Validation


    =IF(B5>0,AND(C5>=0,C5<=11),AND(C5>=0,C5<=9999999))

    Logical_test B5>0
    Value_if_true AND (C5>=0,C5<=11)
    Value_if_false AND (C5>=0,C5<=9999999))

    Thank you again

  7. #7
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Thanks for your response.

    I tried your suggestion without success, maybe I copied the formula wrong. I am attaching a copy of my revised worksheet with your suggestion. Let me know what I am doing wrong!
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    The formula in cells C5 and C7 were not matching row numbers.
    Use my formula in Post #3 above in Data validation at C5, then copy C5 and paste it in C7.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Quote Originally Posted by TINHAMMER View Post
    I am not familiar with the AND statement and how it is used in an IF statement.
    One thing to keep in mind for a custom data validation rule is that the formula must return a value of TRUE or FALSE. If it returns TRUE, then the user's value is allowed, but if FALSE then the user's value is rejected. It looks like you sorted out how the logic works but I'll walk through it anyway:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Thanks that did work. I appreciate your response.

    One thing I did realize with both your response and that from 6StringJazzer, if I go back and change the entry in column B and don't change the entry in column C the entry in column C may not meet the Data Validation criteria.

    I not sure there is any way to avoid that.

  11. #11
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2404
    Posts
    1,259

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Data validation works as a response.
    It will not “see” what has been entered unless you press Enter.
    For a solution beyond that, a VBA solution is required.
    If you dig further in search on keywords such as cascade dropdown vba, maybe you’ll find what you’re after.
    Happy hunting!

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Quote Originally Posted by TINHAMMER View Post
    if I go back and change the entry in column B and don't change the entry in column C the entry in column C may not meet the Data Validation criteria.
    Right, data validation is only checked at the time you enter the data in C. That's just the way it works.

    If you need something more dynamic, then as Estevaoba says you need a VBA solution.

  13. #13
    Forum Contributor
    Join Date
    04-01-2019
    Location
    USA Ohio, Fremont
    MS-Off Ver
    Office 365
    Posts
    128

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Thanks for the input.

    Now that I understand that it is a response I understand how it works. I may have to breakdown and learn vba!!!

  14. #14
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Two Data Validation Rules for a Cell based on entry in Adjacent Cell

    Start by reading up on the Worksheet_Change event.

+ 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. Clear cell contents based on adjacent cell entry
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2018, 05:37 AM
  2. Replies: 3
    Last Post: 12-18-2015, 03:16 PM
  3. Replies: 2
    Last Post: 11-18-2015, 09:37 AM
  4. Replies: 10
    Last Post: 10-07-2013, 11:29 AM
  5. Prohibit data entry based on adjacent cell
    By davemus in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-15-2013, 03:30 AM
  6. [SOLVED] Data Validation Formula based on adjacent cell
    By nawas in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-05-2013, 06:40 PM
  7. validation rules not working when someone copy paste data on validation cell
    By jthakrar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2010, 03:36 AM

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