且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Excel工作表上填充列表框的第2+列

更新时间:2021-09-07 07:04:15

这对我有用.如果以下内容在您的系统上不起作用,请删除列表框,然后重新创建它,然后重试此代码.

This works for me. If the below doesn't work on your system then delete the listbox and re-create it and then try this code again.

Private Sub CommandButton1_Click()
    With ListBox1
        .Clear
        .ColumnCount = 2

        For i = 1 To 2
            .AddItem
            .List(i - 1, 0) = "Col1, Row" & i
            .List(i - 1, 1) = "Col2, Row" & i
        Next i

    End With
End Sub