+ Reply to Thread
Results 1 to 2 of 2

Listbox Column Heading Help

  1. #1

    Listbox Column Heading Help

    I'm trying to populate a listbox with VBA.

    I can't figure out a way to get column headings.

    This is my code.

    With UserForm1.ListBox1
    .ColumnCount = 2
    .RowSource = ""
    .ColumnHeads = True
    .Enabled = True
    .ColumnWidths = "70 pt;100 pt"
    End With


    With UserForm1.ListBox1
    .AddItem
    .List(.ListCount - 1, 0) = "test1"
    .List(.ListCount - 1, 1) = "test2"
    .AddItem
    .List(.ListCount - 1, 0) = "test1"
    .List(.ListCount - 1, 1) = "test2"
    ' Etc, etc

    End With


    It loads the values but I can't get headings.

    I want to do this in code, as the headings I want are "Date","Amount" but
    they don't exist anywhere on my workbook at this point.

    Thanks in advance,
    Alan Sawyer

  2. #2
    Tom Ogilvy
    Guest

    Re: Listbox Column Heading Help

    You can only use column headings if you use the rowsource property to fill
    the listbox. Then you can put the column headings in the row just above the
    rowsource range.

    --
    Regards,
    Tom Ogilvy


    <[email protected]> wrote in message
    news:[email protected]...
    > I'm trying to populate a listbox with VBA.
    >
    > I can't figure out a way to get column headings.
    >
    > This is my code.
    >
    > With UserForm1.ListBox1
    > .ColumnCount = 2
    > .RowSource = ""
    > .ColumnHeads = True
    > .Enabled = True
    > .ColumnWidths = "70 pt;100 pt"
    > End With
    >
    >
    > With UserForm1.ListBox1
    > .AddItem
    > .List(.ListCount - 1, 0) = "test1"
    > .List(.ListCount - 1, 1) = "test2"
    > .AddItem
    > .List(.ListCount - 1, 0) = "test1"
    > .List(.ListCount - 1, 1) = "test2"
    > ' Etc, etc
    >
    > End With
    >
    >
    > It loads the values but I can't get headings.
    >
    > I want to do this in code, as the headings I want are "Date","Amount" but
    > they don't exist anywhere on my workbook at this point.
    >
    > Thanks in advance,
    > Alan Sawyer




+ 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