View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default custom sort by vba


Add a column that contains the length of the cell text.
Sort both columns by the text column (using xlTextAsNumbers).
Sort both columns by the length column.
Clear or delete the length column.
--
Jim Cone
Portland, Oregon USA
(trial version of "Special Sort" add-in available upon request - 2 dozen ways to sort)



"SteveDB1"

wrote in message
Morning all.
A colleague and I are trying to make a macro that will sort a series of
numbers in ascending order. However, we've found that what happens is that it
does not take into account the number of characters are in each number.
I.e., here is a sample
01234, 3245, v01456, 54678, 3765, 4568, 11234, 7534

what we've found is that the numbers are arranged as follows.
11234, 3234, 3765, 4568, 54678, 7534, 01234, v01456

What we'd like is:
3234, 3765, 4568, 7534, 01234, 11234, 54678, v01456
i.e., in an ascending, qty of digits, numbering.

How would we accomplish doing this?

If you have any questions to help better clarify, please ask.

Our present code set is placing these numbers in the builtin document
properties comment block. It's working fine except for this last part or
ordering the numbers the way we need them ordered.
Thank you in advance.
Best.