Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA验证任何值_Excel_Vba - Fatal编程技术网

Excel VBA验证任何值

Excel VBA验证任何值,excel,vba,Excel,Vba,我想知道有没有一种方法可以验证XLeAnyValue?我制作了一个用户表单,用于在验证框中输入注释。所以基本上我不需要任何确认,只需要评论。我知道如何创建一个评论,但我想这样做验证的方式 Private Sub CommandButton25_Click() With ActiveCell.Validation .Add Type:=xlValidateWholeNumber .InputTitle = Me.TextBox1.Value .InputMessage = Me.TextBo

我想知道有没有一种方法可以验证XLeAnyValue?我制作了一个用户表单,用于在验证框中输入注释。所以基本上我不需要任何确认,只需要评论。我知道如何创建一个评论,但我想这样做验证的方式

Private Sub CommandButton25_Click()
With ActiveCell.Validation
 .Add Type:=xlValidateWholeNumber
 .InputTitle = Me.TextBox1.Value
 .InputMessage = Me.TextBox2.Value

End With

Unload InputForm

End Sub

如果您查看了的文档,您会发现有一个允许以下内容的:

Type:=xlValidateInputOnly
您可以使用公式=TRUE作为验证条件。