+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12

    How to use multi-column ListBox?

    Hi,

    I am trying to use a ListBox with multiple columns. I have set the properties so that columncount is 4 and columnheads is true and I can see the four distinct columns when the code is run. However, I can only seem to add data into the first column. I have tried changing the bound column or textcolumn but when I use AddItem, it always puts data in the first column.

    Can anyone give me an example of how to populate all the columns in a ListBox please?

    Thanks

  2. #2
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,445
    Where are you populating from? is the source on a sheet?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  3. #3
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12
    It will eventually use an ADO Recordset but for test purposes I am just trying to hard-coded text to the columns. eg. ListBox1.AddItem "Hello".

    How would I put "Hello" in the first column and "Goodbye" in the second one?

  4. #4
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,445
    Like this
    Code:
       With Me.ListBox1
            .AddItem "hello"
            .List(.ListCount - 1, 1) = "Goodbye"
        End With
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  5. #5
    Registered User
    Join Date
    12-09-2008
    Location
    Hertfordshire, England
    Posts
    12

    Re: How to use multi-column ListBox?

    Great, that worked a charm! Thanks for your help.
    Core 2 Quad Q6600 o/c @ 2.9GHz, 4Gb DDR2 1066MHz, HD5770 1Gb 850MHz, 2 x 750Gb HDD (RAID 0), Benq G2222HDL 22" 1920 x 1080 LED, Win7 Ultimate

    Toshiba Satellite A665-11M, 16" 1366 x 768, i7 720QM 1.6GHz, 4Gb DDR2 1066MHz, GT330M 1Gb, 500Gb HDD, Win7 Home Premium

    Amiga 1200, 3.1 ROM, Blizzard 1230-IV 68030 50MHz CPU, 68882 FPU, 16Mb, 4Gb CF-based HDD, Custom IDE CDROM Drive, Indivision AGA Scandoubler, Custom VGA output, CWB 3.1 ADVSP, Benq G2222HDL 22" 1920 x 1080 LED (720p resolution)

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.2.0