|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 WANT-T 于 2022-11-8 16:32 编辑
把数据整合到一个表里,做个二级菜单的功能不就都有了?
向单元格添加列表的代码:
- 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
复制代码 一维数组转字符串:
- Public Function 一维数组转字符串(SourceArray, Optional Delimiter As String = ",") As String
- 一维数组转字符串 = Join(SourceArray, Delimiter)
- End Function
复制代码 利用ADO+SQL,查询数据,转成一维数组,然后就可以了用上面的代码了!
|
|