Consulting

Results 1 to 3 of 3

Thread: Sort list Box

  1. #1
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location

    Sort list Box


    I have the following code that poulates a list box on a form
    With lstAcc
    ReDim aryItems(1 To iLastRow)
    For i = 2 To iLastRow
    If Cells(i, "A").Value = idx Then
    .AddItem Cells(i, "B").Value
    .List(.ListCount - 1, 1) = Cells(i, "C")
    .List(.ListCount - 1, 2) = Cells(i, "D")
    End If
    Next i
    End With
    How can I sort the list based on the values in the third column in the list box (column D)
    Column D will be sequence number

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sort the worksheet range, and pop it in.
    ____________________________________________
    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
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location
    Quote Originally Posted by xld
    Sort the worksheet range, and pop it in.
    Sometimes I think I am looking too hard for a solution and forget the obvious
    Just sorting the worksheet by column D solves the problem

Posting Permissions

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