#1
|
|||
|
|||
How to sort numbers within a cell
Is there a formula to sort numbers within a Cell.
Eg cell A1 contains "8,5,20,6,14,3" and I want cell B1 to read "3,5,6,8,14,20" |
#2
|
||||
|
||||
Code:
=TEXTJOIN(",",TRUE,SORT(FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s"))) |
#3
|
|||
|
|||
Does not work for me. It says function not valid
|
#4
|
|||
|
|||
I think the TEXTJOIN command only works in Excel 2019 and above (365, etc.)
|
#5
|
||||
|
||||
Would a user-defined function be OK?
2022-01-27_204200.png Code:
Function CellSort(cll) x = Split(cll, ",") For i = LBound(x) To UBound(x) - 1 For j = LBound(x) To UBound(x) - 1 - i If CDec(x(j)) > CDec(x(j + 1)) Then temp = x(j): x(j) = x(j + 1): x(j + 1) = temp Next j Next i CellSort = Join(x, ",") End Function |
#6
|
||||
|
||||
|
#7
|
|||
|
|||
Here is a classical way to do it; see image below
Sort_Image.jpg |
#8
|
||||
|
||||
@ Balge54
- This thread is three months old - Post code as text and wrap it with code tags - an image is quite useless and not everybody has the time to retype your solutions
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#9
|
|||
|
|||
Agree! I should've thought of it. Sorry!
|
Tags |
excel 2010, sort |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sort/select by duplicates containing cell colour | JamesTheNoob | Excel | 3 | 04-08-2019 09:11 AM |
Sort numbers in Ascending order | btserver | Excel | 5 | 03-16-2019 07:54 AM |
Cell references don't change on sort | gebobs | Excel | 3 | 07-23-2015 05:14 AM |
Search a cell that contains words and numbers and convert the numbers to metric | Carchee | Excel Programming | 36 | 10-08-2014 03:16 PM |
Trying to autofilter 8-10 rows of numbers to sort in a group | Jack-P-Winner | Excel | 0 | 11-25-2013 10:55 PM |