|
楼主 |
发表于 2024-3-6 16:43
|
显示全部楼层
类似这段代码,这段代码是把指定文件夹中的所有文件名显示在下拉菜单中,我现在要的是把ACCESS文件中的表名下拉显示出来,其中说的那几个表名不显示,要是那几个表名不显示做不到的话那就全部显示出来也行
Dim mypath$, MyName$, arr$(), m&
If Worksheets("内部参数").Cells(2, 7) = "" Then
mypath = ThisWorkbook.Path & "\excel\"
Else
mypath = Worksheets("内部参数").Cells(2, 7) & "\excel\"
End If
MyName = Dir(mypath & "*.xls")
Do While MyName <> ""
m = m + 1
ReDim Preserve arr(1 To m)
arr(m) = MyName
MyName = Dir
Loop
Sheets("参数").Activate
[iv1].CurrentRegion.Clear
[iv1].Resize(m) = Application.Transpose(arr)
Range("B2:B6").Select
With Range("B2:B6").Validation
.Delete
If m Then .Add 3, 1, 1, "=" & [iv1].CurrentRegion.Address
End With |
|