[翻译]  Combine list and custom formula data validation in one cell within excel without vba

[CHINESE]  在excel中的一个单元格中组合列表和自定义公式数据验证,而无需vba

Can anyone help with a way of combining list and custom formula data validation in a single cell without using vba? I have a custom formula which validates the data if logical is TRUE but I want the user to have ability as well to select from a drop down list. Any assistance will be appreciated. Thanks.


Sorry if the question wasn't so clear enough. Please see below:


enter image description here

In this example, even though the user is able select from a dropdown list, if the user selects 7 for cell A2, the validation should throw out an error because it is not less than or equal to cell B2. Is it clearer?


3 个解决方案



This non-VBA solution combines a conditional with a dropdown picklist. It provides 2 different picklists, dependent on value in another column.


This is different than the oft-shared cascading-lists method (but do see the link for some great techniques)


Let's say you have a table with two columns. Field1 may contain anything:

假设你有一个包含两列的表格。 Field1可能包含任何内容:


Requirement: Field2's validation should display List1 dropdown list when Field1 contains a, and display List2 when Field1 contains anything else.


Solution: Relies on the fact that an Excel conditional formula can return a range containing a list of items.




  • Create a list of picklist-values on a lookup-sheet, and name it List1.
  • 在查找表上创建一个picklist-values列表,并将其命名为List1。
  • Create another list on the lookup-sheet, and name it List2.
  • 在查找表上创建另一个列表,并将其命名为List2。
  • On your entry-sheet, insert a Table object containing 2 columns. Name the table MyTable, and the fields Field1 and Field2.


    enter image description here

  • Create the following defined name, and call it ValidFmla. This is the secret sauce:


    =IF(MyTable[@Field1]="a", List1, List2)

    = IF(MyTable [@ Field1] =“a”,List1,List2)

  • Select the entry-cells in Field2, and click Validation on the data-ribbon.


  • Choose "List" type, and enter =ValidFmla
  • 选择“列表”类型,然后输入= ValidFmla
  • test it out:


    enter image description hereenter image description here



  • It will not break if you change your table name, field names, list-names, or validation-formula name-- all dependent stuff updates automatically.

    如果您更改表名,字段名,列表名或验证公式名称,它将不会中断 - 所有依赖项自动更新。

  • supports any complex conditions you want, as long as your validation formula returns a list-range. Validation does not have to be based on the values in Field1.


  • the validation list-ranges can be named anything. the dependent-lists method requires naming the validation list-ranges the same as the values in the first field.

    验证列表范围可以命名为任何名称。 dependent-lists方法需要命名验证列表范围与第一个字段中的值相同。

Note, you do not have to use a Table object to use this method. But, using the Table object provides structured-referencing in the validation formula, which is a smarter, more readable way to build formulas.




Save we want to setup DV in cell B1 so:


  • if a number is entered, it must be less than the value in A1
  • 如果输入数字,则必须小于A1中的值
  • if text is entered, it must be in the list from D1 throughD3
  • 如果输入文本,则它必须位于D1到D3的列表中

Here is the formulaic DV to do that:


enter image description here

The formula combines numeric tests with the ability to restrict input to some fixed list.




I know this thread is older, but for completeness I am also going to offer another solution that is non-VBA. The OP I don't believe was seeking methods to provide dependent lists as per most of the solutions offered, instead he wants his options list to exist as-is and instead provide additional validation on the actual selection being performed.

我知道这个线程较旧,但为了完整性,我还将提供另一个非VBA的解决方案。 OP我不相信正在寻求根据提供的大多数解决方案提供依赖列表的方法,而是他希望他的选项列表按原样存在,而是对正在执行的实际选择提供额外的验证。

This actually needs to use a different feature of Excel to provide this insight to yourself easier. Conditional Formatting. As per the OP's screenshot provided originally:


Highlight column A, click Conditional Formatting (Home Tab for me) > New Rule. Select the last option, custom formula one, and use the formula:



Click Formatting button, change the background or some other colouring so the validation is made obvious, click OK. See screenshot for results, you still setup your data validation list as per normal for the user to select values from. One thing to note, is that this does not stop the input, it merely provides a visual confirmation that the input is wrong.


Screenshot of results




© 2014-2018 ITdaan.com 粤ICP备14056181号