我知道此问题已被覆盖过,我已尝试查看所有答案,但我仍然收到以下错误
1004 error: Application-defined or object-defined error.
以下是代码:
With ActiveSheet.Range("A10").Validation
.Delete
.Add Type:=xlValidateList, Formula1:=Join(DPHeight, ",")
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
DPHeight
是先前生成的动态数组。
代码在
.Add
行
感谢任何帮助。谢谢
答案 0 :(得分:0)
Option Explicit
Sub TetMe()
Dim DPHeight As Variant
DPHeight = Array("34", "46", "67")
With ActiveSheet.Range("A10").Validation
.Add Type:=xlValidateList, Formula1:=Join(DPHeight, ",")
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
End Sub
然后检查A10的值。应该是一个数据验证列表。