VBA验证列表的默认值

问题描述 投票:3回答:1

有什么方法可以在VBA中创建验证列表时显示默认值?到目前为止,我有:

.Cells(j, 7).Validation.Add Type:=xlValidateList, Formula1:="=" & "Listname"
excel vba validation
1个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.