vba 包含逗号字符的数据验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18722398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Data Validation to Include Comma Character
提问by Gary's Student
I am using the following short macro to assign Data Validation as a list of characters:
我使用以下短宏将数据验证分配为字符列表:
Sub DVList()
With ActiveCell.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="a,b,c,d"
.IgnoreBlank = True
End With
End Sub
The macro works.
宏有效。
I want to modify the macro to include the comma character in the list. I don't see how to do this because the comma is the list separator.
我想修改宏以在列表中包含逗号字符。我不知道该怎么做,因为逗号是列表分隔符。
Am I stuck having to use worksheet cells to build the list??
我是否不得不使用工作表单元格来构建列表?
回答by LS_???
A far as I could test, you can't escape ,
in list.
据我所知,您无法,
在列表中逃脱。
But you can reference a range. You can build a range (in, eg, a hidden sheet), fill cells with all possibilities and make Formula1 := "=HiddenSheet!A1:A10
.
但是你可以引用一个范围。您可以构建一个范围(例如,在隐藏的工作表中),用所有可能性填充单元格并制作Formula1 := "=HiddenSheet!A1:A10
。