VBA验证列表的默认值

时间:2015-01-23 19:47:55

标签: excel vba validation

在VBA中创建默认值时,是否可以从验证列表中显示默认值?到目前为止,我有:

.Cells(j, 7).Validation.Add Type:=xlValidateList, Formula1:="=" & "Listname"

1 个答案:

答案 0 :(得分:6)

不确定。只需在添加验证规则后明确设置单元格的值:)

Dim defaultValue as String 'string right?
defaultValue = ... 'get the value you want from your [ListName]

.Cells(j, 7).Validation.Add Type:=xlValidateList, Formula1:="=" & "Listname"       
.Cells(j, 7).Value = defaultValue