简体   繁体   中英

How can I sort based on descending numbers in a single cell?

I have values in a cell that look like this:

0 AND 
1 AND 
3 AND 
4 AND 
2 OR 

I want the result to looks like this:

0 AND 
1 AND 
2 OR 
3 AND 
4 AND 

Each value is separated by a line break (char(10)). How can I run a small script to sort these values?

Thanks.

Ahh, yes. Thanks for the tip. When I did it your way, it turned out to be super easy!

        Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row, ActiveCell.Column + 1 + totalVals)).Value = splitVals

            ' SORT ASCENDING BOOLEAN VALUES
            Range("BC2").Select
            Range(Selection, Selection.End(xlToRight)).Select
            With ActiveWorkbook.Worksheets("NEW Format").Sort
                .SetRange Selection
                .Apply
            End With
            Range("BC1").Select

I don't need to rejoin at the end. I need to split out this array and concatenate it with elements of another array.

Thank you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM