Comments on: Excel Data Validation: custom formulas and rules

In yesterday's tutorial we started to look at Excel Data Validation - what its purpose is, how it works, and how to use built-in rules to validate data in your worksheets. Today, we are going to take a step further and talk about the nitty-gritty aspects of custom data validation. Continue reading

Comments page 4. Total comments: 286

  1. In my drop-down list i have 3 options (1,2.3), from this when i have choose 1 and 3 i should receive error message. when choose 2 i don't want error message. can you help me.

  2. One more item in the list can be validating field based on conditional values from other fields.

    For example:
    1. Value in Sheet2!B2 should be a date greater than or equal to the date found using vlookup of Sheet2!A2 on Range Sheet1!A:D for D column, and less than similar vlookup on another range.
    2. Value in B2 should be some percentage of sum of value from some other range.
    3. Value in B2 should be either from the list from some other range, or should be from a list from some other range 2.
    4. Value in B3 should be in (the list/range + B2), and so on... That is, adding previous value to the list in the data validation.

    These kind of validations are more common in our day to day work. Simple list validations or date validations are very simple to use.

  3. Hi Alexander, thanks for your answer.

    I have done the regular drop-down list.
    Now, what I need is to be able to select data from the list in cell A1 and get it to show me "blue", whilst on cell B1, I select the same item on the same list but I get it to show me "1".
    Do you understand what I mean?

    Thanks for your help.

  4. Hi there,

    I have a cell with a data validation list dropdown. I want to make a rule to get the cell to show something different when a particular value of the list is selected. Is this possible?

    For example, let's say I have a list from 1 to 10. I want the list to show all the numbers normally, but I want the 1 to show "Improvement needed!" and the 10 to show "Awesome!", however, I need the list to still be 1 to 10, as I would need to do other operations with the data of that list.

    Thanks for your help.

    1. Hello!
      A regular drop-down list inserts the data it shows into the cell.
      An ActiveX ComboBox (Developer - Insert menu tab) may be suitable for your task.

  5. I want the cell to except only Capital M. How would I that?

    Thanks

    1. Hello!
      I hope you have studied the recommendations in the tutorial above. It contains answers to your question.
      Formula =A1="Capital M"

  6. Can I restrict the entry to one decimal point? The problem is even if I set the format of cell as number with one decimal point, when I enter 0.12, the value is still stored as 0.12 despite the number show in the cell is 0.1.

      1. thanks a lot

  7. Column D has data validation rule to select from a drop down list.

    I wish column E to automatically fill based on a custom rule:

    =VLOOKUP(D2,Suppliers!A:B,2,FALSE) /* No errors when setting up the custom rule.*/

    But when i select a value from the drop down list for cell D2, nothing fills in cell E2.

    Thanks for your feedback.

    1. Hello!
      Unfortunately, without seeing your data it is difficult to give you any advice. Please check out the following article on our blog, it’ll be sure to help you with your task: Excel VLOOKUP not working.
      If there is anything else I can help you with, please let me know.

      1. Hello,

        This is the dropdown list worksheet called Suppliers:
        ----------------------------------------------------------------------------
        Allen & Sons Ltd Water
        Beacham & Sons Ltd Electricity
        Chisholm & Sons Ltd Medical Equipment
        Davidson & Sons Ltd Building Maintenance
        Elias & Sons Ltd Computer Equipment
        Fanshaw & Sons Ltd Window Cleaning
        George & Sons Ltd Gardening

        This is the data entry worksheet:
        -----------------------------------------------
        Supplier (col D) Supplies (col E)
        Allen & Sons Ltd
        Beacham & Sons Ltd
        Chisholm & Sons Ltd
        Davidson & Sons Ltd
        Elias & Sons Ltd

        When I select Allen & Sons Ltd in the Supplier column D, I expected column E to fill automatically with the word Water because of the custom data validation formula, but it remains blank.
        =VLOOKUP(D2,Suppliers!A:B,2,FALSE)

        I know I can make cell E do a VLOOKUP, but I was testing to see if the VLOOKUP function could be incorporated as part of a custom data validation formula.

        This is not a problem, it's just a technical challenge.

        Thank you.

        1. Hello!
          Dropdown list in D1 cannot insert value in E1. In cell E1, you can write down the VLOOKUP formula. Once you select a value in D1, it will find the value you want.
          I hope I answered your question. If something is still unclear, please feel free to ask.

  8. Hi
    Using data validation, I know it is possible to do the below separately:

    1. Create a data validation drop down list (ALT + A + V + V then select list from the 'Allow' field and denote the cell range in the 'Source' field)
    2. Prevent users from entering data into one cell (e.g. cell A2) if another cell (e.g. cell A1) has not yet been populated (ALT + A + V + V then select Custom from the 'Allow' field and insert '=NOT(ISBLANK(A1))' in the 'Formula' field)

    However, I am in need of a combination of both. I need to customise a cell such that if cell A1 is not populated, then cell A2 cannot be populated but, when cell A1 has data inserted, A2 should be able to be populated but only through a drop-down list. May you assist

    1. Using data validation, I know it is possible to do the below separately:
      ...
      2. Prevent users from entering data into one cell (e.g. cell A2) if another cell (e.g. cell A1) has not yet been populated (ALT + A + V + V then select Custom from the 'Allow' field and insert '=NOT(ISBLANK(A1))' in the 'Formula' field)
      ...

      How do you know that?? It's NOT working!

      ...Does anyone know if it's possible to use as a condition in formula of Data Validation empty cells??

      1. Hello!
        Use the following formula for data validation

        =NOT(ISBLANK(A1))

        Uncheck "Ignore blank". It works.

  9. Does data validation does not read result in formula result?

  10. Hi,

    Just wondering if you can help me with something. I'm trying to create a variable list dependent on a variable value. E.g. If cell equals a number then give me list of job titles relating to that number.
    I say its variable because the number depends on which department is selected. The job titles are on a separate worksheet within the workbook. The list is variable because job titles can be added or removed to the list so I can't label specific ranges.
    Essentially I want to do a vlookup but the result being a list rather than a single value... is this possible and if so please let me know how to do this!

  11. First row of my spreadsheet is the column titles.
    In row 2 I have four Data Validation drop downs, each column drop down is dependent upon whichever item is picked in the drop down in a previous cell in the same row, but not necessarily adjacent columns. All is working correctly in row 2
    The spreadsheet has 500 data entry rows to allow recording of approx. 6 to 10 jobs per day. How do I extend the Data Validation List rules to all 500 rows?
    I have used Copy/Paste Special/Validation on each column but this is not working correctly. Is the copy/paste method I am using the wrong one for this application?

    1. Hello!
      The information you provided is not enough to understand your case and give you any advice.
      What data validation formula are you using? Specify in more detail what problem occurs in this case.

    2. Above issue resolved. Was a syntax error in one of the formulae where $C$4 was locking drop-down lists to a single cell.

  12. Hi,

    We have a spreadsheet that currently monitors the jobs our contractors are at, and the total hours worked overall for the week. We have the list of employees on the one sheet, and we use the Data Validation drop down to select the jobs for the hours, and I was wondering if there is a formula to also calculate the number of hours based on each specific job, as well as the overall total hours I have listed.

    Thanks.

  13. I want to know formula to list down the data validation list when x collum value is Yes else it shoud show not applicable. please help

    1. Hello!
      Explain what the phrase "list when x collum value is Yes" means? Is each cell in the column "Yes"?
      Please describe your problem in more detail. Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you.

  14. Hi, I have a requirement to allow multiple set of numbers in a cell, for example, (00001, 02334, 01289), retaining leading 0s and limit to 5 digits each number, how can I write a formula for this? can someone help me, thanks

    1. Hello!

      If I understand your task correctly,
      Set the cell to "Text" format and use Data Validation - Allow - Text length

      If you want to use numbers, set the custom format "00000" in the cell and use the Data Validation formula
      =A1<1000000

      I hope it’ll be helpful.

      1. Hi, thanks for getting back on this, the formula and the steps mentioned works for one set of number given on that cell, for example, 00012. My requirement was to enter multiple set of numbers, for example (00012, 11111, 12359, 88888, etc...) which does not work.

        1. Hello!
          I wrote this formula based on the description you provided in your original comment. Please note that if you’d provided me with the precise and detailed description of your task from the very beginning, I’d have created a different formula that would have worked for your case. However, even now your question is not precise enough. 00012, 11111, 12359, 88888 written as text in one cell? If so, why are you talking about numbers and leading 0s?

  15. =AND(COUNTIF(Root_Rank,O6)0,O6<=3)

  16. Why might a logically TRUE formula trigger a FALSE in Custom Validation.
    =AND(COUNTIF(Root_Rank,O6)0,O6<=3) is TRUE when O6 is 1, 2, or 3 but fails validation.

    1. Sorry formula truncated. =AND(COUNTIF(Root_Rank,O60, O6<=3)

  17. I have written a custom public function which returns a true or false value, and I have tested it in a cell and it works. But when I use the function in the formula field on the Data Validation Criteria pop up, I get this error: "A named range you specified cannot be found" The only range in my formula is a cell reference. Any help would be appreciated

    1. Unfortunately, without seeing your data it hard to give you advice. For me to be able to help you better, please describe your task in more detail. Please specify what formula you used and what problem or error occurred. It’ll help me understand it better and find a solution for you. Thank you.

  18. Hi team,
    For some reason this validation rule is not triggering the stop alert in cell E9 when I enetr "X". $R$6=3 and I have entered "X" in three other worksheets in cell "E9". I wonder if you can help-
    =SUMPRODUCT(COUNTIF(INDIRECT('Sheet names'!$E$2:$E$7&"!"&CELL("address",E9)),"*"&"X"&"*"))>$R$6

    1. Hello!
      I’m sorry but your task is not entirely clear to me.
      Please describe your problem in more detail.Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you. Thank you.

    2. I figured it out. Just realized that the alert is triggered by "False" argument, not "true" argument. I just had to change the formula to "".

  19. Hi,
    I'm having difficulty with a custom Data Validation formula. I want it to check two nearby cells for existing values of 1; both these cells must not contain 1 (so if either does contain 1, the validation fails).
    I've tried creating a macro but no matter what it does, it always fails to validate. I then tried entering a formula which works when tested in the sheet, but it always fails to validate when entered as a formula in Data Validation. Any clues please?
    =AND(INDIRECT(ADDRESS(ROW(),COLUMN()+1,4))1,INDIRECT(ADDRESS(ROW(),COLUMN()+3,4))1)

    1. Obviously the system here doesn't like my greater-than/lesser-than symbols as it's stripped them out of my formula!! Here it is again but without using those symbols:-

      =AND(INDIRECT(ADDRESS(ROW(),COLUMN()+1,4))not equal to 1,INDIRECT(ADDRESS(ROW(),COLUMN()+3,4))not equal to 1)

      1. Hello Teresa!
        In the conditional formatting and data validation formula, the INDIRECT function does not work with the logical functions IF, AND, OR, and others. Therefore, I recommend that you divide your formula into 2 parts and create 2 conditions.

        =INDIRECT(ADDRESS(ROW(),COLUMN()-1,4))<>1

        and

        =INDIRECT(ADDRESS(ROW(),COLUMN()+1,4))<>1

        I hope this will help

  20. Hello Dear Sir,
    How can I do for folling,
    "Data validation allows copy paste if it is validated number.If not, data validation reject this data."

  21. How to restrict equal to sign (=) in excel cell

  22. How do i lock a validation rule but can enter data in the cell

    1. Hello!
      It is not possible to block a data validation rule. It can only be deleted. More sophisticated data validation methods are possible using the VBA macro.

  23. Dear Alexander,
    Thank you for engaging to this thread once again. Despite the news are not what I was hopping for, still, excel carrying on the end result is something I kinda expected to tell you the truth.
    If it wasn't necessary to have an alternative zero value in every cell, it would be much easier. I might write all the formulas I need manually, and create separate data validation for every cell. It might take me some time, but it'll totally worth the effort.
    Thank you for your assistance. You're all great in Ablebits at what you're doing. Don't stop giving out essential and helpful hints!

  24. Hello Ablebits team,
    I'm having a hard time to figure out how to make options of a drop-down list, containing formulas, working with relative reference when I paste special with validation in another cell, without using VBA if possible.
    For example, when I copy validation from cell P31, including a list option with the formula "=MIN($D31;$K31+L31)" and paste it to cell P33, I need this formula to change automatically into "=MIN($D33;$K33+L33)".
    Could that be possible in anyway? Thank you in advance!

    1. Hello Yannis!
      When you copy cells, data validation formulas change in the same way as regular formulas. You can check it yourself.

      1. Hello Alexander and thank you for your quick response,
        I've tried it before and it seems not to be working, since the result I get by selecting this list component, is the same for every cell I paste the validation into.
        Let me clarify that it's a list containing the formula (including the value zero and the formula) and not a custom validation, where I could write the formula directly into the box while creating it, in case this detail is of any importance.
        Is there any worksheet setting I should turn on or off?

        1. Yannis,
          Thank you for the clarification. I mush have misunderstood your previous comment. I supposed you're using a custom validation formula applied to some data range and this formula is the one that doesn't get updated. If however, it is the range with different formulas you've set as the data validation source range, those formulas won't be recalculated when copying. You see, Excel uses not the formula but the end result for the validation, no matter where this validation list is.
          I hope this will help, otherwise please do not hesitate to contact me anytime.

  25. Hi,
    I am working on the excel to validate specific texts cannot be entered into the cell. Example, when user keys in Hello or HELLO or bye or NA, the cell will show specific text entered is not allowed. If user keys other text, it will be allowed to be entered into the cell. Appreciate your help to list out the formula to resolve this probllem. Thanks

  26. Column B Defines the scope of the product with two variables Yes or No e.g. Cell B1 = Yes/No
    Column C - Cell C1 has data validation of three parameters Simple/Medium/Complex.
    If the value of Cell B1 is Yes for the Scope; then only Cell C1 should get activated and the user should be able to choose the type of the parameter by clicking the drop-down arrow i.e. Simple/Medium/Complex.
    Please advise the formula or procedure to do the same.
    Best Regards

  27. Dear All I am from India, please help me I got fade of to make this 'custom data validation isuue solved. I made a table having multiple column.
    Column 'C' contains 'Items in innitial Stock', 'D' contains 'No. Of Used items', and 'E'containes 'Faulty items'.

    Now three isuue are that (1) 'E' cant be greater than either the 'C'or 'C-D' and (2) if Stock 'C' is empty/blank no Entry should be allowed in 'E'.
    And (3) if C is having 20 items and no item is used (it means 'D' is balnk), but some items foud faulty, so 'E' must not be greater than 'C'. And it must generate erro message if these condition violated.
    I tried more than 50 Formula but it satisfied only 2 conditions.
    plase help to make this formula.

    1. Hello Santosh,
      Please try the following formula for data validation for cell E3:

      =IF(AND((C3-D3)>=E3,C3>0,C3>=E3), TRUE, FALSE)

      You can learn more about Data Validation in Excel in this article on our blog:
      https://www.ablebits.com/office-addins-blog/data-validation-excel/#custom-data-validation-rules
      https://www.ablebits.com/office-addins-blog/excel-data-validation-custom-formula/

      Hope you’ll find this information helpful.

  28. Hello,
    I am working on excel and for the specific columns i need to restrict the data-entry of " ."(space and dot, consecutively). For such validation which command should i use.
    Help.

  29. I'm trying to set up a validation rule to connect the value in one column to an appropriate valid value list in another column. For example, I have a validated cell (let's say B2) where the value is validate via a list on Sheet 2 in cells A1-A3. THe valid values in the list include three names: Paul (A1), Peter (A2) and Pamela (A3). Now, on sheet 2 I have a list of Paul's prefered toys in Cells C1-C10, Peter's list is in D1-D10 and Pamela's are in E1-E10. Now, back on Sheet 1 I want to create a validation formula in Cell B3 that says...... Refer to cell B2, if the value in the cell is the value in Sheet 2, Cell A1 then select from the list in Sheet 2, between cells C1-C10. If it's A2, then select from the list in sheet 2 cells D1-D10, and so forth. Is this possible? Another way to look at this is, I want to limit choice number 2 based on choice number 1. If I'm making a selection for Pauls' Christmas present, I only want to see the things on Pauls' Christmas list. Thanks for any help you can provide.

  30. Please Help me someone. How can I use two data validation in a column? I want only 9 digits to be entered in a cell and if it's more then 9 or less then 9 it should not accepted. and also this number should be uniqe in the column

  31. To whom it may concern,

    Question,

    What is the formula for picking a month from a drop down list/pick list and enter the value for the start date(cell 1) and end date(cell 2) within that month.

    For example:

    1. I selected the month of the January from the drop down list and I will put value on cell 1 as the start date and cell 2 as the end date and will calculate the number of remaining days based on the formula =Networkdays(cell1, cell2).

    That being said, only January dates will be acceptable as this is the current value selected in the pick list.

    Thank you.

  32. How can I disallow a value from being entered into one cell based on the value in a different cell? For example, if Cell A1 has the value "ABC" then no data can be allowed to be entered in cell B1 and a rejection message displayed if possible.

  33. While doing a validation, can I have the If rule set i.e if the value in column A is selected then the appropriate list pertaining to the selected value only should appear in column B and others should be disabled.

  34. Please help me in this case: I want to create the long formula for data validation but when i type the formula it was limited character. So what could i do to complete my data validation formula?

  35. I am trying to use formula and list for data validation. For example, I have 2 columns, in the first column is the highest possible value can be chosen in the second column, I also want the user to choose from the list and not to type in their choice.

    Whenever the user chooses a value greater than the value in the first column, there should be an error message. can this be done with data validation?

  36. I want to mention in data validation, Yes,No or Other. But in other i want to put column blank as they will specify the requirement if they select other

  37. Hello there,

    I really appreciate the detailed information present on your Website i am stucked at one place in excel want to know if there is any Formula or VB Script which can help me.

    I am making a Leave management excel Template from my Office everything is perfect except the date.

    eg. if User X has applied leaves from 01-01-2019 till 15-01-2019

    I Blocked User Y to apply the Leaves from 1st Jan till 15 via Data Valitation not between field so now he can apply after (15-01-19 till 25-01-19)

    Now on the third row for User z i don't know what to do if i want to block dates for User X + User Y (i.e. User Z should not choose any dates from 01-01-2019 till 15 Jan 2019 & 15-01-2019 till 25-01-2019).

    I hope i made it clear.

    Thank you in advance.

    Regards,
    Muzamil.

  38. Hi,
    I like to have a data validation combined for the entry
    number 1 to 10 or the text "OK"
    would this be possible?
    thanks
    Cor

  39. Hi Ablebits Team,
    I checked your blog post. You're simply brilliant! I have researched a lot, and by far your responses are best.
    Here is my issue-
    I maintain a product sales workbook with different sheets for each month. Column A specifies the invoice number and has custom data validation rule for unique entries following preset case sequence and character limit(eg-ABC1234q1we).
    This works fine. Not an issue. However, i want to be able to apply the same validation rule to all sheets in the workbook to avoid duplicate entry. [Currently, I am consolidating data from each sheet to one master sheet and checking if Invoice number is unique before copying it to required sheet.]

    Is there a way around this where I can extend the validation rule between all sheets in the workbook? Plus, also consider, that new sheets maybe added to the workbook later and at that point the rule needs to be applied to include this new sheet as well.
    Please guide me with your expertise!

  40. Hi what should i do in the validation data if I only want either TCY or TTL to be written on the cells selected?

  41. About my question, someone helped me and the answer is:
    =and(counta(b2)=0;countif($a$2:$a$42;a2)=1)

  42. I have 3 drop-downs (one in column A, B & C). Column A will have names, Column B will have catalog names and Column C will have item codes). I want to show multiple values in Column C based on what was selected in Columns A & B. So if I kept the name the same from column A but changed the category in Column B, then Column C will return different values based on the selection from Column B (or even A). How do I write this formula in the Data-Validation list?

    1. hello bobby,
      first you wanna a data can put one sheet and go select table you select area change in table and go to formula option select define name first select heading than put name than now per column wise heading not select only heading data select and define name heading wise and use main sheet data validation.

  43. I wanna use this formula in data validation but I dont know why it dose not answer truly
    =AND(IF(B2>0;0;1);COUNTIF($A$2:$A$42;A2)=1)

  44. Trying to create a validation where If a range of cells (in my case c5:c8) must have a value greater than 0 in order for anyone to enter any value in cell range g5:g10. I created a custom formula in cells g5:g10 that reads, =c5:c8>0 and this validation only works when a number is recorded in C5. If I enter a number in any other cell in range (c6-c8) I get the error in g5-g10. DO not know where I am going wrong. Thank you!

  45. Hello - I would like a warning to pop up if a calculated cell exceeds a limit. Is it possible? The calculated cell is creating a percent - we do not want it to exceed 100%. I can do an IF calculation in another cell, but would prefer a warning message. Thank you!

  46. f4 -> list type having two vlues - free and cash
    g4 should be based on f4 i.e if f4 is free then 100 else 0
    so i want validation that if f4= free then you can not change value of g4
    and if f4=cash then user can change value that i did with data validation custom condition
    f4"free" then you can not change value

    problem is when i change free to cash - i am able to change value suppose i made it 20
    now if i am change f4="free" it doesn't changing value of g4= 100

  47. Please I am trying to do a cell validation for text such that if the cell was ignored and left blank, It will display an error message.

    I know if you input a text and then delete it, it would display the intended error message. However, I found if you just ignore and skip the cell, no error message is displayed.

    How do I resolve this?? Like I do not want any cells omitted or ignored and file can't be closed/saved unless information is complete.

    I used the custom, unchecked "ignore blank" and formula : istext()

    1. You can't do this with data validation.
      Specifically, you can't prevent the user closing/saving the file half-way through. You could possibly do that with VBA/macro code that is triggered when the file is closed and checks the status of a checkcell.
      Without VBA, you could use Conditional Formatting to highlight the empty cells, as well as Data Validation as you describe. That would alert the user to the empty cells, but you can't stop them closing or saving the file.

      1. Thanks Chadwick. I thought as much too that I will probably need VBA to do that.

  48. Hello, I want to restrict the cell with certain alphabet and certain range of numerical value to design a mark ledger of students. I tried to do it but I couldn't. Please, help me.

    1. Hello Amit Kr. Karn
      Formula Use in Data Validation Option
      there formula
      =AND(ISnumber(A1),LEN(A1)=10)
      Number Validation 10 digit
      there formula text validation 10 text
      =AND(IStext(A1),LEN(A1)=10)

      i hope you try.

  49. Sorry I completely forgot to escape my angle brackets
    A2:-
    =IF(B2="",AND(A2>=TIME(0,0,1),A2<=TIME(11,59,59)),AND(A2>=TIME(0,0,1),A2<=B2-TIME(0,0,1)))
    B2:-
    =IF(A2="",AND(B2>=TIME(0,0,1),B2<=TIME(11,59,59)),AND(B2>=A2+TIME(0,0,1),B2<=TIME(11,59,59)))

  50. Apologies that formula again
    =IF(A2="",AND(B2>=TIME(0,0,1),B2=A2+TIME(0,0,1),B2<=TIME(11,59,59)))

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)