Display all columns in listbox from searched row.

  • I am learning listboxes today :) My code below populates a listbox from a searched range. Everything works fine but i would like to know how to make this code display 10 columns instead of 2. Thanks for your time.

    the column count function doesnt work.

    [SIZE=3]The Only Dumb Question Is A Question Not Asked.[/SIZE]

  • Re: Display all columns in listbox from searched row.


    Assuming your ListBox is created directly in your UserForm (rather than programmatically) then you simply change its ColumnCount to 10 or whatever is needed. You then need to modify your loop to load the data in it with each column being selected by the second number in the List property for LsBx_View. Be aware that the indexes (row and column) start from 0 not 1.

  • Re: Display all columns in listbox from searched row.


    Do not use additem to populate a listbox/combobox with multiple items.
    Use .List instead.
    Populate a listbox/combobox in the userform's Initialize event.


    Code
    Private Sub Userform8_initialize()
       With Listbox1
          .List=sheets(1).usedrange.value
          .columncount=ubound(.list,2)
       End With
    End Sub


    That's all

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!