在多列列表框中添加数据

Add data in listbox in multiple columns

最近我遇到了一个用户,该用户的列表框在第一列中显示工作表名称,属性 比如它们在第二列中是可见还是隐藏。但是当我试图访问它的锁的代码时,我用谷歌搜索并做了所有事情来理解它是如何完成的,但我没有找到它希望我在下面得到我的答案是我的代码,我是菜鸟,请帮助我

我的代码:-

Private Sub UserForm_Initialize()

Dim ws As Worksheet


ListBox1.ColumnCount = 2
For Each ws In ThisWorkbook.Worksheets

    Me.ListBox1.AddItem ws.Name

Next ws

End Sub

有几种可能性。其中之一是:

Sub ListBoxMitArrayAusTabelleFuellen()
 Dim VarDat As Variant
 Dim lngRowMax As Long

 With Tabelle1

  lngRowMax = .Range("A" & .Rows.Count).End(xlUp).Row
  VarDat = .Range("A2:B" & lngRowMax ).Value

  .ListBox1.ColumnCount = UBound(VarDat, 2)
  .ListBox1.Clear
  .ListBox1.List = VarDat

 End With

End Sub

背景 伯恩德

Private Sub UserForm_Initialize()

    Dim ws As Worksheet, n As Long, arText
    arText = Array("xlSheetVisible", "xlSheetHidden", "", "xlSheetVeryHidden")
    
    ListBox1.ColumnCount = 2
    For Each ws In ThisWorkbook.Worksheets
        Me.ListBox1.AddItem ws.Name
        Me.ListBox1.List(n, 1) = arText(ws.Visible + 1)
        n = n + 1
    Next ws

End Sub