+ Reply to Thread
Results 1 to 2 of 2

Colum heads in multcolumn listbox

  1. #1
    Alen32
    Guest

    Colum heads in multcolumn listbox

    I got here code which display multicolum list box. I would like to have
    column heads in listbox. If it's possible my colum heads are in celle
    F12:F14.

    Option Explicit
    Private Sub ListBox1_Change()
    With Me.ListBox1
    If .ListIndex > -1 Then
    'MsgBox .List(.ListIndex, 1)
    ThisWorkbook.FollowHyperlink _
    Address:="Http://" & .List(.ListIndex, 1)
    End If
    End With
    End Sub

    Private Sub UserForm_Initialize()
    Dim cell As Range
    Dim sh As Worksheet

    With Me
    .ListBox1.RowSource = ""
    .ListBox1.ColumnCount = 3
    .ListBox1.Clear
    End With

    Set sh = Worksheets("Ark1")

    For Each cell In sh.Range("A10:A250")
    If cell.Value = sh.Range("A5").Value Then
    With UserForm1
    .ListBox1.AddItem cell.Value
    .ListBox1.List(.ListBox1.ListCount - 1, 1) _
    = cell.Offset(0, 2).Value
    .ListBox1.List(.ListBox1.ListCount - 1, 2) _
    = cell.Offset(0, 5).Value
    End With
    End If
    Next

    End Sub






  2. #2
    Tom Ogilvy
    Guest

    Re: Colum heads in multcolumn listbox

    column headings don't work unless you fill the listbox using rowsource.

    --
    Regards,
    Tom Ogilvy

    "Alen32" <[email protected]> wrote in message
    news:[email protected]...
    > I got here code which display multicolum list box. I would like to have
    > column heads in listbox. If it's possible my colum heads are in celle
    > F12:F14.
    >
    > Option Explicit
    > Private Sub ListBox1_Change()
    > With Me.ListBox1
    > If .ListIndex > -1 Then
    > 'MsgBox .List(.ListIndex, 1)
    > ThisWorkbook.FollowHyperlink _
    > Address:="Http://" & .List(.ListIndex, 1)
    > End If
    > End With
    > End Sub
    >
    > Private Sub UserForm_Initialize()
    > Dim cell As Range
    > Dim sh As Worksheet
    >
    > With Me
    > .ListBox1.RowSource = ""
    > .ListBox1.ColumnCount = 3
    > .ListBox1.Clear
    > End With
    >
    > Set sh = Worksheets("Ark1")
    >
    > For Each cell In sh.Range("A10:A250")
    > If cell.Value = sh.Range("A5").Value Then
    > With UserForm1
    > .ListBox1.AddItem cell.Value
    > .ListBox1.List(.ListBox1.ListCount - 1, 1) _
    > = cell.Offset(0, 2).Value
    > .ListBox1.List(.ListBox1.ListCount - 1, 2) _
    > = cell.Offset(0, 5).Value
    > End With
    > End If
    > Next
    >
    > End Sub
    >
    >
    >
    >
    >




+ 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