Sort data based on the right hand value within a cell containing a string of data

%3CLINGO-SUB%20id%3D%22lingo-sub-2691466%22%20slang%3D%22en-US%22%3ESort%20data%20based%20on%20the%20right%20hand%20value%20within%20a%20cell%20containing%20a%20string%20of%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2691466%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20copied%20data%20from%20another%20source%20into%20a%20column%20x%20multiple%20rows.%26nbsp%3B%20The%20data%20within%20the%20column%20is%20of%20various%20widths%20and%20the%20text%20to%20column%20function%20will%20not%20satisfy%20to%20move%20the%20data%20to%20another%20column%20that%20I%20can%20sort%20on%20as%20it%20is%20picking%20up%20some%20of%20the%20other%20text%20contained%20in%20the%20cell.%3C%2FP%3E%3CP%3EThe%20data%20that%20I%20want%20to%20sort%20is%20the%20end%20value%20within%20the%20cell%2C%20is%20there%20a%20way%20of%20sorting%20the%20data%20based%20on%20the%20right%20hand%20value%20in%20the%20cell.%26nbsp%3B%20(I%20have%20formatted%20the%20data%20to%20align%20on%20the%20right%20hand%20side%20and%20it%20is%20this%20that%20I%20want%20to%20sort%20on).%26nbsp%3B%20See%20image.%26nbsp%3B%20Any%20help%20would%20be%20appreciated%2C%20thank%20you%20in%20advance.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22aod2020_0-1630054422703.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F306233iCF27E88C6EFC9DAD%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22aod2020_0-1630054422703.png%22%20alt%3D%22aod2020_0-1630054422703.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2691466%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2691480%22%20slang%3D%22en-US%22%3ERe%3A%20Sort%20data%20based%20on%20the%20right%20hand%20value%20within%20a%20cell%20containing%20a%20string%20of%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2691480%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1139231%22%20target%3D%22_blank%22%3E%40aod2020%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDo%20all%20cells%20have%20%22-20%20%22%20or%20%22-DEC-20%20%22%20before%20the%20value%20on%20which%20you%20want%20to%20sort%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2691602%22%20slang%3D%22en-US%22%3ERe%3A%20Sort%20data%20based%20on%20the%20right%20hand%20value%20within%20a%20cell%20containing%20a%20string%20of%20data%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2691602%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1139231%22%20target%3D%22_blank%22%3E%40aod2020%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20following%20assumes%20that%20there%20will%20always%20be%20...-nn%20(from%20a%20date%20in%20DD-MMM-YY%20format)%20before%20the%20value%20you%20want%20to%20sort%20on.%3C%2FP%3E%0A%3CP%3ELet's%20say%20the%20data%20are%20in%20A2%20and%20down.%3C%2FP%3E%0A%3CP%3EIn%20B2%2C%20enter%20the%20following%20formula%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DMID(RIGHT(SUBSTITUTE(A2%2C%20%22-%22%2C%20REPT(%22-%22%2C%20255))%2C%20255)%2C%20FIND(%22%20%22%2C%20RIGHT(SUBSTITUTE(A2%2C%20%22-%22%2C%20REPT(%22-%22%2C%20255))%2C%20255))%2B1%2C%20100)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFill%20down.%3C%2FP%3E%0A%3CP%3ESelect%20B2%2C%20then%20sort.%3C%2FP%3E%0A%3CP%3EP.S.%20This%20will%20treat%20all%20end%20values%20as%20text.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi,  

I have copied data from another source into a column x multiple rows.  The data within the column is of various widths and the text to column function will not satisfy to move the data to another column that I can sort on as it is picking up some of the other text contained in the cell.

The data that I want to sort is the end value within the cell, is there a way of sorting the data based on the right hand value in the cell.  (I have formatted the data to align on the right hand side and it is this that I want to sort on).  See image.  Any help would be appreciated, thank you in advance.

aod2020_0-1630054422703.png

 

4 Replies

@aod2020 

Do all cells have "-20 " or "-DEC-20 " before the value on which you want to sort?

@aod2020 

The following assumes that there will always be ...-nn (from a date in DD-MMM-YY format) before the value you want to sort on.

Let's say the data are in A2 and down.

In B2, enter the following formula:

 

=MID(RIGHT(SUBSTITUTE(A2, "-", REPT("-", 255)), 255), FIND(" ", RIGHT(SUBSTITUTE(A2, "-", REPT("-", 255)), 255))+1, 100)

 

Fill down.

Select B2, then sort.

P.S. This will treat all end values as text.

@Hans Vogelaar  thank you so much for taking the time to answer my query.  It works a treat and has saved me a huge amount of time.