我正在尝试向Range
个单元格添加和删除数据验证(以及inCellDropdown)。它第一次运行时工作正常。但我总是在后续执行中遇到错误。
我得到的错误是“HRESULT异常:0x800A03EC”
这是代码:
If type = "a1" Then
Try
Me.Range("A1:A20").Validation.Delete()
Me.Range("A1:A20").Validation.Add(Type:=Excel.XlDVType.xlValidateList, _
AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, _
[Operator]:=Excel.XlFormatConditionOperator.xlBetween, _
Formula1:="=rangedname1")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
ElseIf type = "b2" Then
Try
Me.Range("A1:A20").Validation.Delete()
Me.Range("A1:A20").Validation.Add(Type:=Excel.XlDVType.xlValidateList, _
AlertStyle:=Excel.XlDVAlertStyle.xlValidAlertStop, _
[Operator]:=Excel.XlFormatConditionOperator.xlBetween, _
Formula1:="=rangedname2")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
EndIf
之前有没有人处理过这个问题?