Excel下拉列表框
输入错误时
实现代码如下
Sub test()
With Range("e5").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Sheet3!$A$1:$A$300"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "输入标题"
.ErrorTitle = "错误标题"
.InputMessage = "输入信息"
.ErrorMessage = "错误信息,请选择相应的数据,如果没有有效数据请联系,在sheet3的 a300填写"
.IMEMode = xlIMEModeNoControl
.ShowInput = True
.ShowError = True
End With
End Sub
参考链接
验证对象 (Excel) | Microsoft Learnhttps://learn.microsoft.com/zh-cn/office/vba/api/excel.validation特此记录
anlog
2023年6月7日