+ Reply to Thread
Results 1 to 6 of 6

populate multi column list box

  1. #1
    Registered User
    Join Date
    07-30-2009
    Location
    melbourne, AUS
    MS-Off Ver
    Excel 2003
    Posts
    33

    populate multi column list box

    howdy

    i have a multi column list box with 3 columns on a user form, when i try to populate it with column A B C of sheet 1 it keeps adding all columns from sheet 1 to the first column of list box, i cant work out why?
    any suggestions?
    thanks

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: populate multi column list box

    What code are you using? Have you set the columns count property to 3?

    Dim rSource As Range
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-30-2009
    Location
    melbourne, AUS
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: populate multi column list box

    this is my current code:

    Sub LoadlistBox()

    Dim Cell As Range
    Dim Data As Variant
    Dim I As Long
    Dim Rng As Range
    Dim RngEnd As Range

    ListBox1.Clear
    ListBox1.ColumnCount = 3

    Set Rng = Worksheets("Sheet1").Range(.Cells(2, 1))
    Set RngEnd = Rng.Parent.Cells(Rows.Count, Rng.Column).End(xlUp)
    Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, Rng.Parent.Range(Rng, RngEnd))

    For Each Cell In Rng
    If Trim(Cell) <> "" Then
    With ListBox1
    .AddItem
    .List(.ListCount - 1, 0) = Cell.Text
    .List(.ListCount - 1, 1) = Cell.Offset(0, 1).Address
    End With
    End If
    Next Cell

    End Sub

    thanks

  4. #4
    Registered User
    Join Date
    07-30-2009
    Location
    melbourne, AUS
    MS-Off Ver
    Excel 2003
    Posts
    33

    Re: populate multi column list box

    after closer perusing i see where i went wrong, all fixed

    Thanks anyway.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: populate multi column list box

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: populate multi column list box

    Your post does not comply with Rule 9 of our Forum RULES. If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit. And please never edit a thread in which someone else has responded.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1