简体   繁体   English

如何在单个单元格中基于降序排序?

[英]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)). 每个值都由换行符(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! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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