How can I sort column of combined text & numbers

dbe594

New Member
Joined
Aug 3, 2021
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I have a column of data I'm having trouble sorting....
DGPF45
DGPF450
DGPF51
DGPF511

The smaller numbers are mixed in with the larger numbers in the wrong places, rather than two-digit numbers being sorted first, and then three-digit numbers...
DGPF45
DGPF51
DGPF450
DGPF511

The text always comes first and ends with the "F" character. This should also be able to sort single number values (e.g., DGPF1, DGPF2...DGPF10, DGPF11...DGPF100, DGPF101). I believe our numbers could go as high as DGPF1000.

I know I'm looking at a formula for a "sort column," but I am not getting it right. Would love help with this! :)
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
One possible way is to use this array-entered** formula to create the helper column for your sort...
Excel Formula:
=TEXT(RIGHT(A1,COUNT(-RIGHT(A1,ROW($1:$9)))),"000000000")
**Commit this formula using CTRL+SHIFT+ENTER and note just Enter by itself
 
Upvote 0
Solution
Assuming that there is only ever 1 "F" in the text and that the numeric part is never more than 5 digits.
Excel Formula:
=LEFT(A2,FIND("F",A2))&TEXT(MID(A2,FIND("F",A2)+1,5)+0,"00000")
I've assumed from the wording of your post that the number of letters in the text can vary, if it is always 4 letters ending in F then it can be simplified to something like
Excel Formula:
=LEFT(A2,4)&TEXT(MID(A2,5,5)+0,"00000")
 
Upvote 0
As a formula, since you have office 365

Excel Formula:
=SORTBY(A1:A4,--MID(A1:A4,SEARCH("F",A1:A4)+1,LEN(A1:A4)),1)
 
Last edited:
Upvote 0
One possible way is to use this array-entered** formula to create the helper column for your sort...
Excel Formula:
=TEXT(RIGHT(A1,COUNT(-RIGHT(A1,ROW($1:$9)))),"000000000")
**Commit this formula using CTRL+SHIFT+ENTER and note just Enter by itself
This worked nicely! Thank you!! :D
 
Upvote 0
One possible way is to use this array-entered** formula to create the helper column for your sort...
Excel Formula:
=TEXT(RIGHT(A1,COUNT(-RIGHT(A1,ROW($1:$9)))),"000000000")
**Commit this formula using CTRL+SHIFT+ENTER and note just Enter by itself
Oh Oh. We threw a wrench into the works. Now we have alpha characters after the numeric...

CLVF510
CLVF511
CLVF512
CLVF513
CLVF1A
CLVF1B
CLVF1C
CLVF1D
CLVF2A
CLVF2B
CLVF4Z

Is there any way to adjust the formula to adjust for this?
 
Upvote 0
Oh Oh. We threw a wrench into the works. Now we have alpha characters after the numeric...

Is there any way to adjust the formula to adjust for this?
Your examples all show a single letter (when there is text after the number)... will it always be a single trailing letter (when there is one) or could it be more than one letter?
 
Upvote 0
Your examples all show a single letter (when there is text after the number)... will it always be a single trailing letter (when there is one) or could it be more than one letter?
Ha! The way its going I wouldn't put it past them! ;) But I think we'll have the one letter for a while anyway.
 
Upvote 0
Since you are using XL365, and as long as the only numbers in the cell are the ones you are trying to retrieve, then this should work no matter how many letters are on the end...

=CONCAT(IFERROR(0+MID(A1,SEQUENCE(LEN(A1)),1),""))

The above formula returns the number as text in order to preserve any leading zeros that might be in number. If that is not a concern and you want real numbers returned, then use this instead...

=0+CONCAT(IFERROR(0+MID(A1,SEQUENCE(LEN(A1)),1),""))
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,453
Members
452,915
Latest member
hannnahheileen

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