Consulting

Results 1 to 4 of 4

Thread: Multi listbox

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Multi listbox

    Hope this is a simple one for you

    I have the code below to display a 2 column multilistbox from a dynamic array

    Dim Rng As Range 
    Dim Cell As Range
    Me.ListBox1.Clear
    With ThisWorkbook.Sheets("Exhibits")
    Set Rng = .Range("A2", .Range("A65536").End(xlUp))
    End With
    For Each Cell In Rng.Cells
    With Me.ListBox1
    Me.ListBox1.AddItem Cell.Offset(0, 2).Value
    .List(.ListCount - 1, 1) = Cell.Value
    End With
    Next Cell

    How can I make it for a 4 column listbox?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this.

    Dim LastRow         As Long
    Me.ListBox1.Clear
        With ThisWorkbook.Sheets("Exhibits")
            LastRow = .Range("A65536").End(xlUp).Row
            Me.ListBox1.RowSource = .Range("A2:D" & LastRow).Address
        End With
    Just change the RowSource to the actual range you want.

  3. #3
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Absolutely perfect once again

    Thank you

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •