|
1、通常我们会把代码写到模块里,而不是工作表里;
2、以下内容为,我自己经常用的,向单元格区域添加数据有效性下拉菜单的通用方法:其中参数2:addlist为添加的清单,是一个以英文逗号拼接的字符串;如,"内容1,内容2,内容3",直接调用这个过程,输入对应的参数,即可!
- Public Sub 向单元格添加列表(rng As Range, addlist As String)
- With rng.Validation
- .Delete
- .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=addlist
- .IgnoreBlank = True
- .InCellDropdown = True
- .InputTitle = ""
- .ErrorTitle = ""
- .InputMessage = ""
- .ErrorMessage = ""
- .IMEMode = xlIMEModeNoControl
- .ShowInput = True
- .ShowError = False
- End With
- End Sub
复制代码 3、祝工作顺利,天天开心;
|
|