I have a spreadsheet that I am sorting based on an “item number” column. So if the item number column has the following values:
2.2
2.1.b
I want the row with the 2.1.b to be before the 2.2 row. However, the sort function in Excel puts 2.2 ahead. It must determine value based on the # of characters.
Is there a way to do sort the column in VBA?
This can easily be done in Excel by creating a “Custom List” and then sorting on that list.
Custom Lists allow you to create your own default sort order. You can create a new Custom List as follows “0,1,2,3,4,5,6,7,8,9,.,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z”. You can add to this if your sorting needs further logic.
This new list will then sort according to numbers first, the a period, then a letter.
You create the list, when sorting for the first time select “Custom Sort”, choose your new list, and you’re done. Now when you sort, the data will be sorted according to your new criteria.