简体   繁体   English

Excel数据验证(带有或不带有vba)

[英]Excel Data Validation (with or without vba)

I have a column of cells eg "column C" whereby I would like to input a data validation. 我有一列单元格,例如“ C列”,我想输入数据验证。

I would like to restrict users to key in either "Done", "NA" or "any dates eg 01/10/2016, 31/03/2013 etc" 我想限制用户键入“完成”,“不适用”或“任何日期,例如01/10 / 2016、31 / 03/2013等”

How do I create the above data validation? 如何创建以上数据验证? I am alright with using either Excel's "Data validation" function or VBA. 我可以使用Excel的“数据验证”功能或VBA。

Thanks 谢谢

Pretty simple bit of code here you could make to do whatever, highlight the cell or something, this just sets it back to blank. 您可以在此处做一些非常简单的代码,以突出显示单元格或其他内容,只需将其设置为空白即可。 I would also desensitize them to caps and add some other options like "n/a" 我还将使他们对上限不敏感,并添加其他一些选项,例如“ n / a”

Private sub worksheet_change(byval target as range)
   If Target.Value <> "Done" And Target.Value <> "NA" And Not IsDate(Target.Value) Then
      MsgBox ("incorrect entry, enter only blah or blah...")
      Target.Value = ""
   End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM