您好,我有以下代码来在组合框中显示工作表。创建工作表后,工作表会自动添加到列表中。
我不希望隐藏的工作表在保管箱中可见。我怎么做?
Option Explicit
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex > -1 Then Sheets(ComboBox1.Text).Select
End Sub
Private Sub Combobox1_DropbuttonClick()
Dim xSheet As Worksheet
On Error Resume Next
Application.screenupdateing = False
Application.EnableEvents = False
If ComboBox1.ListCount <> ThisWorkbook.Sheets.Count Then
ComboBox1.Clear
For Each xSheet In ThisWorkbook.Sheets
ComboBox1.AddItem xSheet.Name
Next xSheet
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Combobx1_Gotfocus()
If ComboBox1.ListCount <> 0 Then ComboBox1.DropDown
End Sub
这就是你正在尝试的吗?
Private Sub Combobox1_DropbuttonClick()
Dim xSheet As Worksheet
'~~> Clear the bocmbobox
ComboBox1.Clear
'~~> Add the sheet again
For Each xSheet In ThisWorkbook.Sheets
'~~> Check if they are visible
If xSheet.Visible = xlSheetVisible Then
ComboBox1.AddItem xSheet.Name
End If
Next
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)