Sort within rows in same column

sharshra

Active Member
Joined
Mar 20, 2013
Messages
404
Office Version
  1. 365
I have to sort the comma separated text in each row in a column. Note that I´m not sorting the rows, but text within each row only. At present, I´m using the formula to do this in a separate column. Instead, I want to get the same result on the original column itself.

For example, consider the table below. Column J has comma separated text. I´m able to sort the text in each row as seen in column K. I want to get the same result in column J.

excel problems.xlsx
JK
3dd,aa,mmaa,dd,mm
4bbbbbb
5kk,tt,cc,2e2e,cc,kk,tt
6p,yup,yu
7ij,gt,fx,w,m6tfx,gt,ij,m6t,w
8hh
9df,aoao,df
10pmk,q,88,un,zt88,pmk,q,un,zt
11ec,blbl,ec
1272,hp,fv72,fv,hp
Sheet8
Cell Formulas
RangeFormula
K3:K12K3=DROP(REDUCE("",$J$3:$J$12,LAMBDA(x,y,VSTACK(x,TEXTJOIN(",",TRUE,SORT(TOCOL(TEXTSPLIT(y,","))))))),1)
Dynamic array formulas.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Are the values in column J hard-keyed (static values)? Or are they the result of some other formula? If they are static values, you'll need the helper column. To overwrite the values in column J, just Copy the results in column K (Ctrl+C), then Paste Special > Values in column J (Ctrl+Alt+V).

By the way, DROP-REDUCE-VSTACK is overkill in this situation (not to mention slow with larger datasets). You can achieve the same results with MAP:

Excel Formula:
=MAP(J3:J12,LAMBDA(v,TEXTJOIN(",",,SORT(TEXTSPLIT(v,,",")))))

Tip: use the [row_delimiter] argument of TEXTSPLIT (instead of col_delimiter) to output vertically.
 
Upvote 1
Solution
Thanks, @djclements. Column J has static values. I´m already using helper column & copying the values. But wanted to check if there is any better way.

Thanks for your suggestion on MAP (y)
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top