João Lima
João Lima

Reputation: 55

Can't add two columns to listbox in a userform

I have two columns which I'm trying to add to a listbox. The first column has general numbers and the second one has time formatted numbers. When I select a column individually, it shows up in the listbox. The problem is, when I select them both, only the first one is added.

I'm using multiple listboxes and the ranges change in each iteration.

The code I wrote to populate the listboxes is this:

With Controls("Listbox" & k + 1)
        .RowSource = "Sheet1!" & Range(Cells(2, i), Cells(97, i + 1)).Address
End With

What could be happening?

Upvotes: 1

Views: 280

Answers (1)

basodre
basodre

Reputation: 5770

Did you set the ColumnCount property to 2 (either using code, or using the ListBox properties).

An example:

With Me.ListBox1
    .ColumnCount = 2
    .RowSource = "Sheet1!A1:B10"
End With

Upvotes: 1

Related Questions