验证对象 (Excel)

代表工作表区域的数据有效性规则。

示例

使用 Range 对象的 Validation 属性可返回 Validation 对象。 下例更改单元格 E5 的数据有效性规则。

Range("e5").Validation _ 
 .Modify xlValidateList, xlValidAlertStop, "=$A$1:$A$10"

使用 Add 方法可将数据有效性添加到某个区域并创建一个新的 Validation 对象。 此示例向单元格 E5 添加数据有效性检验。

With Range("e5").Validation 
 .Add Type:=xlValidateWholeNumber, _ 
 AlertStyle:=xlValidAlertInformation, _ 
 Minimum:="5", Maximum:="10" 
 .InputTitle = "Integers" 
 .ErrorTitle = "Integers" 
 .InputMessage = "Enter an integer from five to ten" 
 .ErrorMessage = "You must enter a number from five to ten" 
End With 

方法

属性

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。