Excel Multicolumn Listboxes. How to manually add additional data before data is inserted

I populate a multicolumn listbox with data from an array.
However, I would like to add one or two additional values manually before the array is populated that will appear at the top.

This is how I populate the listbox

With Me.lstContracts
.ColumnCount = 4
.ColumnWidths = "40,150;100,100"

    If arrContracts(x, colRecyclingContractCustomerID) = CustomerID Then
            .AddItem
            .List(.ListCount - 1, 0) = arrContracts(x, 1)
            .List(.ListCount - 1, 1) = arrContracts(x, colRecyclingContractSubscriptionName)
            .List(.ListCount - 1, 2) = arrContracts(x, colRecyclingContractFirstPickup)
            .List(.ListCount - 1, 3) = arrContracts(x, colRecyclingContractLastPickup)
    
    End If

End With
Next x

Open in new window


I understand that .addItem has an optional parameter that would allow me to specify the index but it looks like this only works in single column listboxes - not in multi like mine.
I would like to add a value 0 and/or 1

Any ideas how to solve this?

Thanks
Massimo ScolaAsked:
Who is Participating?
 
NorieVBA ExpertCommented:
It should work in a multi-column listbox.

Here I've added a row at the top and filled it with some arbitrary values.
    With Me.lstContracts
        .ColumnCount = 4
        .ColumnWidths = "40;150;100;100"
    
        ' code to populate listbox from array

        ' add row at top and populate it
        .AddItem , 0
        .List(0, 0) = "TopRowCol1"
        .List(0, 1) = "TopRowCol2"
        .List(0, 2) = "TopRowCol3"
        .List(0, 3) = "TopRowCol4"
    End With

Open in new window

0
 
Massimo ScolaAuthor Commented:
Oh that's great - I can even add two values to it before I add data from an array to the listbox. Thanks for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.