Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2022, 07:55 AM
ferozefahad ferozefahad is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2010
Novice
How to sort numbers within a cell
 
Join Date: Jan 2022
Posts: 2
ferozefahad is on a distinguished road
Default 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"
Reply With Quote
  #2  
Old 01-27-2022, 10:14 AM
p45cal's Avatar
p45cal p45cal is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Code:
=TEXTJOIN(",",TRUE,SORT(FILTERXML("<t><s>"&SUBSTITUTE(A1,",","</s><s>")&"</s></t>","//s")))
2022-01-27_171303.png
Reply With Quote
  #3  
Old 01-27-2022, 10:51 AM
ferozefahad ferozefahad is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2010
Novice
How to sort numbers within a cell
 
Join Date: Jan 2022
Posts: 2
ferozefahad is on a distinguished road
Default

Does not work for me. It says function not valid
Attached Images
File Type: png Excel.png (16.7 KB, 35 views)
Reply With Quote
  #4  
Old 01-27-2022, 12:08 PM
kilroyscarnival kilroyscarnival is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2019
Expert
 
Join Date: May 2019
Posts: 344
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

Quote:
Originally Posted by ferozefahad View Post
Does not work for me. It says function not valid
I think the TEXTJOIN command only works in Excel 2019 and above (365, etc.)
Reply With Quote
  #5  
Old 01-27-2022, 01:04 PM
p45cal's Avatar
p45cal p45cal is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

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
Reply With Quote
  #6  
Old 03-12-2022, 08:20 AM
p45cal's Avatar
p45cal p45cal is offline How to sort numbers within a cell Windows 10 How to sort numbers within a cell Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Quote:
Originally Posted by p45cal View Post
Would a user-defined function be OK?
Clearly not.
Reply With Quote
  #7  
Old 04-20-2022, 01:40 PM
Balge54 Balge54 is offline How to sort numbers within a cell Windows 11 How to sort numbers within a cell Office 2016
Novice
 
Join Date: Apr 2022
Posts: 6
Balge54 is on a distinguished road
Default

Here is a classical way to do it; see image below
Sort_Image.jpg
Reply With Quote
  #8  
Old 04-20-2022, 11:59 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline How to sort numbers within a cell Windows 7 64bit How to sort numbers within a cell Office 2010
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,766
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

@ 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
Reply With Quote
  #9  
Old 04-21-2022, 11:27 AM
Balge54 Balge54 is offline How to sort numbers within a cell Windows 11 How to sort numbers within a cell Office 2016
Novice
 
Join Date: Apr 2022
Posts: 6
Balge54 is on a distinguished road
Default

Agree! I should've thought of it. Sorry!
Reply With Quote
Reply

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
How to sort numbers within a cell 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

Other Forums: Access Forums

All times are GMT -7. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft