Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.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

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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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 数据验证是否包含逗号字符_Excel_Vba - Fatal编程技术网

Excel 数据验证是否包含逗号字符

Excel 数据验证是否包含逗号字符,excel,vba,Excel,Vba,我使用以下短宏将数据验证指定为字符列表: Sub DVList() With ActiveCell.Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="a,b,c,d" .IgnoreBlank = True End With End Sub 宏可

我使用以下短宏将数据验证指定为字符列表:

Sub DVList()
    With ActiveCell.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:="a,b,c,d"
        .IgnoreBlank = True
    End With
End Sub
宏可以工作

我想修改宏以在列表中包含逗号字符。我不知道怎么做,因为逗号是列表分隔符


我是否不得不使用工作表单元格来构建列表???

据我所知,您无法在列表中转义


但是你可以参考一个范围。你可以构建一个范围(例如,在一个隐藏的表格中),用所有可能的方式填充单元格,并使
公式1:=“=HiddenSheet!A1:A10

@pnuts我不知道如何将=CHAR(44)构建到我的公式1中string@pnuts这将与简单地键入
…@pnuts相同-您的解决方案工作得很好!谢谢!@pnuts编写
“a,b“
“a”和Chr(44)和“b”完全相同”
。。。但我现在注意到了:您忽略了VBA。@pnuts好的,我这么想是因为您误用了
CHAR
而不是
Chr
。请记住,如果要在VBA字符串中插入不受支持的字符,可以使用
Chr
<代码>,不适用,它在字符串中有效。问题是这是一个列表分隔符。我将此标记为答案,但在代码中使用了“pnuts”。谢谢你的帮助!我想说的是,我尝试了你的解决方案,它奏效了。因此,我将你的回答标记为答案。