How to sort SR4.2-10,11,8,9 to SR4.2-8,9,10,11 by VBA as shown in attached excel?
How to sort SR4.2-10,11,8,9 to SR4.2-8,9,10,11 by VBA as shown in attached excel?
Unfortunately you need to break down the cell into its component parts, and then format the numerical elements so that they are the same length, otherwise it sorts numbers like text, which is what is causing you the problem.
This formula will convert the string in one go (assuming there are always 2 alpha characters in positions 1 and 2
Formula:
Please Login or Register to view this content.
And you can use this value to sort in the usual way
In the attached workbook I have broken that formula down for you in separate columns which may be easier to follow!
Last edited by Kevin#; 04-08-2016 at 01:14 PM.
If a response has helped then please consider rating it by clicking on *Add Reputation below the post
When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)
Hello london7871,
Here is another approach with VBA. I have used the Macro Recorder which will hopefully make it easier for you to understand. You may play around with it and change your ranges to suit.
I have moved the Data Range down to start at Row3. All you now need to do is to hit on the "Click Me" - button in the attached sample Workbook below.![]()
Please Login or Register to view this content.
HTH
Regards.
Please consider:
Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .
Try this code
![]()
Please Login or Register to view this content.
You could use a UDF in an extra column and sort by that:
Row\Col A B C 1 Input Sort 2SR4.2/10 SR04.02/10 B1: =padnum(A1, 2) 3SR4.2/11 SR04.02/11 4SR4.2/8 SR04.02/08 5SR4.2/9 SR04.02/09
![]()
Please Login or Register to view this content.
Entia non sunt multiplicanda sine necessitate
Hello london7871,
I have adapted the Code to allow for any length of Data in ColumnA. Please replace the Code in the sample Workbook in Post #3 with the Code below:
![]()
Please Login or Register to view this content.
Regards.![]()
Please Login or Register to view this content.
Last edited by Winon; 04-08-2016 at 02:00 PM. Reason: Added reset Code
Hi London7871
Here's another approach...
![]()
Please Login or Register to view this content.
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
How to sort different format as below as per attached excel:
SR4.3/8,9; SR4.2/10,11,7+1,7A to SR4.2/7A,7+1,10,11;SR4.3/8,9 ?
Hi london7871,
You were offered you a couple of solutions to your original request, without you acknowledging any of them. I don't think I will be far off by saying, that members might be less inclined to try and help you again.
Common courtesy could earn you some respect, if you at least thank one or more of the contributors to your original request, and then hopefully you may receive further assistance.
In Post #8 you could add something like:
Thank you for your understanding.Hi guys,
Thank you for all your help. Sorry but could we expand it to "How to sort different format as below as per attached excel:
SR4.3/8,9; SR4.2/10,11,7+1,7A to SR4.2/7A,7+1,10,11;SR4.3/8,9 ?"
Regards.
Last edited by Winon; 04-09-2016 at 11:45 AM.
Sorry Winon and thanks for your help. I'll improve my asking skill.
Hi london7871,
Thank you.
Please confirm if the numbers SR4.3/8,9; SR4.2/10,11,7+1,7A as per your new sample Workbook are the only values of interest, or may there be other variations?
Regards.
Please see attached excel for my actual case.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks