我有一个Userform,它基本上是两个由打开的工作簿填充的组合框。有没有办法可以从这个列表中排除PERSONAL.XLSB?这就是我所拥有的:
Sub UserForm_Initialize()
Dim wkb As Workbook
With Me.ComboBox1
For Each wkb In Application.Workbooks
.AddItem wkb.Name
Next wkb
End With
With Me.ComboBox2
For Each wkb In Application.Workbooks
.AddItem wkb.Name
Next wkb
End With
End Sub
答案 0 :(得分:2)
试
With Me.ComboBox1
For Each wkb In Application.Workbooks
If Not Right(wkb.Name, 4) = "xlsb" Then
.AddItem wkb.Name
End If
Next wkb
End With
如果您不想依赖文件扩展名可见,则可以检查文件格式。
If Not wkb.FileFormat = 50 Then
.AddItem wkb.Name
End If