Consulting

Results 1 to 4 of 4

Thread: Excel userform ListBox multicolumn

  1. #1

    Excel userform ListBox multicolumn

    Hi
    I am new in VBA and trying to get a multicolumn in my ListBox in Excel Userform ,If i select a particular sheet.Presently I can Select a sheet
    but in the List box it is putting all the data in one List

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub CommandButton1_Click()
    Dim i As Long
    Dim wsMyWks As String
    Dim nRow As Long
    Dim mRow As Range

    wsMyWks = ComboBox1.Value

    With Me.ListBox1

    .BoundColumn = 1
    .ColumnCount = 4
    .TextColumn = True

    nRow = Worksheets(wsMyWks).Range("A65536").End(xlUp).Row
    For Each mRow In Worksheets(wsMyWks).Rows("1:" & nRow)

    .AddItem mRow.Cells(1, 1).Value
    For i = 2 To 7

    .List(.ListCount - 1, i - 1) = mRow.Cells(1, i).Value
    Next i
    Next mRow

    End With

    MsgBox "Paste your code to get info from userform to worksheet here"

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    AWESOMEEEEEEEEE

    You are Genius, I was trying to do this from last 2 whole days and you did it in half an hour

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Oh I don't think it took him that long.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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