VBA 仅将"one sheet name"返回到列表框中,用户表单正在初始化,尽管预计会有更多的工作表


Private Sub UserForm_Initialize()
'declare the variable
Dim Sh As Variant
Dim cc As Variant
cc = Sheet4.Range("C4").Value
'for each loop to add sheets based on permission rank
For Each Sh In ActiveWorkbook.Sheets
'add only permitted sheet(ranking 1 to 6) and exclude settings sheet
If Sh.Range("G1").Value >= cc And Sh.Name <> "settings" Then
'add sheets to the list box
Me.lstSheet.AddItem Sh.Name
End If
Next Sh
End Sub

尝试添加我。

这将刷新表单。

考虑将ListBox变量名称从1stSheet更改为sheet1ListBox,以使其更具描述性且更易于调试。

相关内容

  • 没有找到相关文章

最新更新