View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default FileSearch - help

When sorting, the filenames are treated as text, so your sort order is what would be expected.
Only solution is to either pad your numbers with 0's (eg. use "_002_" and not "_2_") or to separate the nubers and text and sort by
the two fields (the numbers being sorted as numeric).

I suspect the view you have from Windows Explorer may be sorted by date and not by filename, so maybe you could consider applying
the same sort in Excel.

--
Tim Williams
Palo Alto, CA




Thank you for very fast response, it is working fine.
Now I noticed another problem with sorting.
This problem was present also before.

In command below:
----------------------------------------------------------------------------
------------------
If .Execute(msoSortByFileName, msoSortOrderAscending, True) 0 Then
----------------------------------------------------------------------------
-----------------------

I should receive file names sorted by name, but this is not working good.
For instance , this files below are sorted in this way:

123456789_1_13.jpg
123456789_1_3397.jpg
123456789_1_3463.jpg
123456789_1_827.jpg
123456789_10_1626.jpg
123456789_10_2550.jpg
123456789_2_2705.jpg
123456789_2_556.jpg

And it should be sorted in this way (this si how it looks in win explorer):
123456789_1_13.jpg
123456789_1_827.jpg
123456789_1_3397.jpg
123456789_1_3463.jpg
123456789_2_556.jpg
123456789_2_2705.jpg
123456789_10_1626.jpg
123456789_10_2550.jpg

It looks like that this subroutine don't understand numbers in file names,
numbers
are represent as text and sorting is performed according that.

In this example my files are named only with numbers, but there are
situations
when they have some letter characters for instance N123456789_24_15.jpg
I there a possibility to solve this problem?

Best Regards!!