Solved

sorting special multicolumn listbox

Posted on 2014-04-05
7
245 Views
Last Modified: 2014-04-05
excel vba
userform
listbox

Need this sorted by column "Col1"  second column

I have data i a listbox that looks like this:
Col0          Col1
Pumps      (3)
Motors      (5)
Fans          (63)
Knives       (1)
Pullys        (101)

I need it to look like:   descending order..please
Col0          Col1
Pullys        (101)
Fans          (63)
Motors      (5)
Pumps      (3)
Knives       (1)


'=====================================================================================
    Dim i As Long
    Dim j As Long
    Dim sTemp As String
    Dim sTemp2 As String
    Dim sTemp3 As String
    Dim sTemp4 As String
    Dim sTemp5 As String
    Dim sTemp6 As String
    Dim LbList As Variant
'
    LbList = Me.ListBox1.List
    For i = LBound(LbList, 1) To UBound(LbList, 1)
        For j = i + 1 To UBound(LbList, 1)
            If LbList(i, 1) > LbList(j, 1) Then
 
                sTemp = LbList(i, 0)
                LbList(i, 0) = LbList(j, 0)
                LbList(j, 0) = sTemp
 
                sTemp2 = LbList(i, 1)
                LbList(i, 1) = LbList(j, 1)
                LbList(j, 1) = sTemp2
 
 
 
            End If
        Next j
    Next i

Open in new window




or some other suggested code?

Thanks
fordraiders
0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 39980847
Are there parenthesis around number? In this case text ordering rules will work:
63,5,3,101,1
You should convert text to numbers (parenthesis should be removed) and then order as decreasing numbers
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39980859
Are there parenthesis around number?
yes
0
 
LVL 40

Expert Comment

by:als315
ID: 39980865
Can you upload sample worksheet?
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 3

Author Comment

by:fordraiders
ID: 39980866
ok even after taking the parenthese out..it still will not sort correctly with the code above.
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39980867
i have data pulling in from our vpn servers...no i cant send the sheet..sorry
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39980903
ok,

i used an old routine:
http://www.ozgrid.com/forum/showthread.php?t=71509

works fine:
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39980904
Thanks
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question