Excel:如何确保单元格包含数字1-6或逗号分隔的数字1-6? [英] Excel: how ensure cells contain numbers 1-6 or comma separated numbers 1-6?

查看:71
本文介绍了Excel:如何确保单元格包含数字1-6或逗号分隔的数字1-6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问答电子表格,其中最多包含两百行.每行中的一列通过输入1到6之间的数字或以逗号分隔的多个答案(例如1、3、5)来表示正确答案.我想在每行强制执行此规则,并且不允许输入其他任何内容.

I have question and answer spreadsheets with up to a couple hundred rows in them. One column in each row indicates a correct answer by entering a number from 1 to 6 or multiple answers separated by commas like 1,3,5. I'd like to enforce this rule on every row and not allow input of anything else.

我发现无法使用自定义数据验证",并且不确定如何在每一行中使用函数.

I find can't a way to use Custom Data Validation and am not sure how to use a function in each row.

推荐答案

  • 选择您感兴趣的范围,例如 A1:A10

    添加以下公式作为自定义数据验证:

    Add the following formula as a custom data validation:

    =IFERROR(FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s[preceding::*=.  or .*0!=0 or .*1>6 or .*1<1]"),"")=""
    

  • 您需要从Excel2013开始,但公式将验证字符串值是否具有

    You'd need Excel2013 onwards but the formula will validate the string value to have:

    • 没有重复的值.
    • 数字之外没有其他值.
    • 没有高于6的值.
    • 没有低于1的值.
    • 只有逗号可以用作有效的分隔符.

    公式中的 A1 是相对的,因此对 A10 的验证将以相同的方式工作,但显然对 A10 进行验证.

    The A1 in the formula is relative so validation for A10 will work just the same way but then for A10 obviously.

    这篇关于Excel:如何确保单元格包含数字1-6或逗号分隔的数字1-6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆