0

我正在尝试为从特定单元格开始的列中的每个单元格创建一个下拉列表。以下是我制作的:

Public Sub Dropdown()
    Dim dvList As String

    dvList = "Option1, Option2, Option3"

    With ActiveSheet.Range("C25").Resize(50, 1).Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula:=dvList
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With
 End Sub

我对这条线有疑问:

.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula:=dvList

当我运行这段代码时,我不断得到:

Run-time error '1004':

Application-defined or object-defined error

我不知道为什么会这样,看来这就是这样做的方法。有人可以指出我的错误吗?

4

1 回答 1

3

尝试将其更改为Formula1:=dvList

于 2012-10-25T21:34:31.657 回答