MobileMobile | Continue

Excel Bar

Excel Bar

Your excel questions will be responsed by our excel experts within 24hrs.Our service is free.

 Forgot Pass?
 Register Now
Find
Hot Search: Vlookup Match VBA
12
Return Post new threads
Author: d.sanchez

Sort for multicolumn listbox in userform (5-columns) [SOLVE

[Copy link]

2

Topics

7

Posts

26

Integral

Member

Rank: 2

Integral
26
Post on 2-11-2017 14:08:14 | All posts



The sort is a bubble sort based on the textual content. In order to sort the dates properly you will need to sort their numeric values rather than the text in m/d/yyyy format.
I have added a extra column, which you can hide using ColumnWidth of zero. When the 2nd column is sorted it uses the extra column values to actually sort on.








  • 964420.xlsm
    (24.7 KB, 7 views)
    Download













  • Reply Support Opposition

    Props Report

    0

    Topics

    3

    Posts

    8

    Integral

    Newbie

    Rank: 1

    Integral
    8
    Post on 2-11-2017 14:54:11 | All posts



    first off all very nice work-a-round idea
    i am learning userforms  by looking at examples and solutions
    in looking at this example 964420  i not that allthough it does everything  OP required.  for me it does not display the first row of your data sheet in the userform
    maybe i am doing something wrong
    regards











    Reply Support Opposition

    Props Report

    0

    Topics

    2

    Posts

    6

    Integral

    Newbie

    Rank: 1

    Integral
    6
    Post on 2-11-2017 15:07:02 | All posts



    Hi Andy,
    That's a very creative solution to the date issue, never would have come up with that on my own
    Thanks!
    Best,
    KB




    Reply Support Opposition

    Props Report

    2

    Topics

    10

    Posts

    28

    Integral

    Member

    Rank: 2

    Integral
    28
    Post on 2-11-2017 16:12:49 | All posts



    @AkaTrouble. In order to display header in a listbox you need to use the rowsource property. This links the listbox directly with cells on the worksheet with the header row being the row immediately above the data. In order to sort the listbox you will need to sort the worksheet.
    Reply Support Opposition

    Props Report

    0

    Topics

    3

    Posts

    8

    Integral

    Newbie

    Rank: 1

    Integral
    8
    Post on 2-11-2017 13:37:00 | All posts



    Yes it does. That is what the SortOn argument in the subs signature is.
    This example will sort the column you double click.








  • 964420.xlsm
    (23.6 KB, 227 views)
    Download













  • Reply Support Opposition

    Props Report

    2

    Topics

    7

    Posts

    26

    Integral

    Member

    Rank: 2

    Integral
    26
    Post on 2-11-2017 19:36:30 | All posts



    Hello Andy,
    I was looking for a code to sort a multicolumn list box and i came across your double click feature which is really impressive!
    So i implemented my excel case into your double click idea but i noticed that the column that has dates doesn't get sorted properly.
    I uploaded a sample of my work.
    Please note that my userform-initialize to populate the list box is constructed differently than yours.
    Thanks!








  • Sort listbox.xlsm
    (25.9 KB, 10 views)
    Download








  • Reply Support Opposition

    Props Report

    1

    Topics

    5

    Posts

    13

    Integral

    Member

    Rank: 2

    Integral
    13
     Author| Post on 2-11-2017 21:25:19 | All posts



    The sort is a bubble sort based on the textual content. In order to sort the dates properly you will need to sort their numeric values rather than the text in m/d/yyyy format.
    I have added a extra column, which you can hide using ColumnWidth of zero. When the 2nd column is sorted it uses the extra column values to actually sort on.








  • 964420.xlsm
    (24.7 KB, 9 views)
    Download













  • Reply Support Opposition

    Props Report

    2

    Topics

    10

    Posts

    28

    Integral

    Member

    Rank: 2

    Integral
    28
    Post on 2-11-2017 22:03:52 | All posts



    first off all very nice work-a-round idea
    i am learning userforms  by looking at examples and solutions
    in looking at this example 964420  i not that allthough it does everything  OP required.  for me it does not display the first row of your data sheet in the userform
    maybe i am doing something wrong
    regards











    Reply Support Opposition

    Props Report

    14

    Topics

    699

    Posts

    1588

    Integral

    King

    Rank: 6Rank: 6

    Integral
    1588
    Post on 2-11-2017 23:38:37 | All posts



    Hi Andy,
    That's a very creative solution to the date issue, never would have come up with that on my own
    Thanks!
    Best,
    KB




    Reply Support Opposition

    Props Report

    1

    Topics

    5

    Posts

    13

    Integral

    Member

    Rank: 2

    Integral
    13
     Author| Post on 2-12-2017 01:13:13 | All posts



    @AkaTrouble. In order to display header in a listbox you need to use the rowsource property. This links the listbox directly with cells on the worksheet with the header row being the row immediately above the data. In order to sort the listbox you will need to sort the worksheet.
    Reply Support Opposition

    Props Report

    12
    Return Post new threads

    Points policy of this forum

    Archiver|Mobile|Small dark house|Contact us|Excel Bar

    GMT-5, 11-20-2017 00:49 , Processed in 0.190602 second(s), 17 queries .

    Powered by Discuz! X3

    © 2001-2013 Comsenz Inc.

    !fastreply! Top !return_list!