我现在搜索了很多,但不知道问题出在哪里。其他人也以相同的方式进行操作,并且有效。
这是我的代码,如果有人可以帮助我,那将是非常棒的。预先谢谢你!
该错误发生在“ .Add Type”行中
Sub dropDownMenu()
Do While (Worksheets("x").Cells(counter + 2, 1) <> "")
counter = counter + 1
Loop
Worksheets("y").Range("D36:D36") = ""
With Worksheets("y").Range("D36:D36").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=x!A2:A" & 1 + counter & ""
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = "xxx"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub