How to make a multicolumn listbox in VBA

To make a multicolumn listbox in VBA you can use the following snippet.
This snippet should also work in VB6.

Sample VBA

Option Compare Database
Option Explicit

Private Sub Form_Load()
    FillListbox
End Sub

Public Sub FillListbox()
Dim i As Integer

Listbox1.Clear
Listbox1.ColumnCount = 4

For i = 0 To 9
    Listbox1.AddItem "Row" + CStr(i) + "; Column1"
    Listbox1.List(i, 1) = "Row" + CStr(i) + "; Column2"
    Listbox1.List(i, 2) = "Row" + CStr(i) + "; Column3"
    Listbox1.List(i, 3) = "Row" + CStr(i) + "; Column4"
Next
End Sub

Please Share us:
Please rate this snippet

One thought on “How to make a multicolumn listbox in VBA

Leave a Reply