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 支援與意見反應