Sort Left to Right based on a Cell Value

srizki

Well-known Member
Joined
Jan 14, 2003
Messages
1,860
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I have data that I sort every month. I want to sort the data based on the column values as follows.
[TABLE="width: 125"]
<tbody>[TR]
[TD]0517HZJ036241005
[/TD]
[/TR]
[TR]
[TD]0517HZJ307583003
[/TD]
[/TR]
[TR]
[TD]0717HZJ036241005
[/TD]
[/TR]
[TR]
[TD]0417HZJ036241005
[/TD]
[/TR]
[TR]
[TD]0417HZJ307583003
[/TD]
[/TR]
[TR]
[TD]0417NNJ036241005
[/TD]
[/TR]
[TR]
[TD]0417NNJ279495002
[/TD]
[/TR]
[TR]
[TD]0417NNJ354507001
[/TD]
[/TR]
[TR]
[TD]0517NNJ036241005
[/TD]
[/TR]
[TR]
[TD]0517NNJ279495002
[/TD]
[/TR]
[TR]
[TD]0517NNJ354507001
[/TD]
[/TR]
</tbody>[/TABLE]

So, this is what I want, I want to sort by the last digits of invoice numbers, such as, 7001, 95002, 83003 etc. so all invoices will be together and will be sorted by month, So it will be easy to find what month(s) is/are missing.

Please advise.

Regards,
 
Last edited:
Use LEFT, RIGHT, and MID function to extract the portion that you want to sort by, and sort on those calculated values.
 
Upvote 0
Hi Sohail

i can think of two ways of cracking this concern

1) simply apply filters, >> Text Filters >> Ends with

2) Add a helper column and apply =RIGHT(B2,5) and thereafter you can filter of required invoice number.

Hope it'll help
 
Upvote 0
Thank you Sandie,

I used text to columns approach, I separated the way I wanted and sorted it. But it would have been nice to sort without going through an extra step.

Thanks
 
Upvote 0
Joe,

Thanks for your always help.
I used text to columns, that worked out well, but had to do more work, that is not always possible. I wish Microsoft add this feature.

Best regards,
 
Upvote 0
I wish Microsoft add this feature.
Add which feature? It already has sorting capabilities.
You can do what you want without Text to Columns by using formulas to extract the values that you want to sort by, like Sandie and I mentioned.
 
Upvote 0
Joe4,
Sorry for the late reply.
Actually I have the following on column A,

\\enterwest.net\shared\Allshare\Houston JIB Accounting\Outside Operated JIB's\sohail's Group JIBs\SOHAIL RIZKI UPLOADS\GD America Production Co\07-2017\0717-0070025032.xlsm

This is where I wanted to sort the column by the filename.

Best regards,
 
Upvote 0
Say your entry is in cell A10. Use this formula to extra just the file name:
Code:
=TRIM(RIGHT(SUBSTITUTE(A10,"\",REPT(" ",99)),99))
(as long as your file name is less than 100 characters long, it should work)

Then you can sort by this column.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,812
Messages
6,193,118
Members
453,777
Latest member
Miceal Powell

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