Here is where we left off in the last post
here is what it looks like in the explorer window:HTML Code:Folder used is F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder Folder First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*.xls*) is AForthThirdAfterwb.xlsx Use 1 in loop of unargumented Dir gives SecondFirstAfterwb.xlsx Use 2 in loop of unargumented Dir gives ThirdSecondAfterwb.xlsx
ExpOrder1.JPG : https://imgur.com/OfQfHeH
I can move the order pysically in the explorer window, by selecting and dragging the file position virtically, ( and I hit the refresh thing , just in case that should influence anything )
ExpOrder2.JPG : https://imgur.com/AlV1MdB
The routine, Sub DirOrder() , then seems to give the same results
HTML Code:Folder used is F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder Folder First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*.xls*) is AForthThirdAfterwb.xlsx Use 1 in loop of unargumented Dir gives SecondFirstAfterwb.xlsx Use 2 in loop of unargumented Dir gives ThirdSecondAfterwb.xlsx
I can do this:
ExpOrder3a.JPG : https://imgur.com/RBSa9Ou
ExpOrder3a.JPG : https://imgur.com/2OVsguZ
Once again I get the same alphabetical ordering in the Dir found order output
i can play around with this:
ExpOrder4.JPG : https://imgur.com/6FbYQgp
or this
Stack by change date.jpg : https://imgur.com/YIrTxpp , https://imgur.com/ht887FU , https://imgur.com/lHMcUjA
Stack by change date.JPG
Once again I get the same alphabetical ordering in the Dir found order output
I made this d_xlsm_file.xlsm , and this ,c_xls_file.xls , and pit it in the foilder, Folder
A xlsm and xls.JPG : https://imgur.com/w9gyRxj
A xlsm and xls.JPG
here is part of my Immediate window output
I need to increase my loop count, Cnt , to 4 to getting total all 5 files. But doing this is likely to get a bit tedious as I comtinue experiments with a different number of files in various folders. So I will change my coding, at the loop section, to a more typical type of loop used iin such a Dir __ file finding code: Usually something like this is done, so that the loop keeps going as long as Dir __ finds filesHTML Code:First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*.xls*) is AForthThirdAfterwb.xlsx Use 1 in loop of unargumented Dir gives c_xls_file.xls Use 2 in loop of unargumented Dir gives d_xlsm_file.xlsm
Here is the full coding, http://www.excelfox.com/forum/showth...ll=1#post11108 , which gives for the last example:Code:‘ First use of Dir with full path and file name argument ‘ strWB = "F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*.xls*" ‘ Wild card to get all Excel Files ‘ File = Dir(strWB) ‘ ‘ ‘ Loop for all files meeting search string criteria, ( all Excel files in this example ) Do ' '_- I want to keep going in a Loop while I still get a file name returned by Dir Dim Cnt As Long: Let Cnt = Cnt + 1 File = Dir: Debug.Print "Use " & Cnt & " in loop of unargumented Dir gives """ & File & """" Loop While File <> "" '_- I want to keep going in a Loop while I still get a file name returned by Dir
HTML Code:F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder Folder First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*.xls*) is AForthThirdAfterwb.xlsx Use 1 in loop of unargumented Dir gives "c_xls_file.xls" Use 2 in loop of unargumented Dir gives "d_xlsm_file.xlsm" Use 3 in loop of unargumented Dir gives "SecondFirstAfterwb.xlsx" Use 4 in loop of unargumented Dir gives "ThirdSecondAfterwb.xlsx" Use 5 in loop of unargumented Dir gives ""
I can change the serach criteria from strWB & "*.xls*" to strWB & "*" and it has no effect
i added a .jpg pic, ( Add a jpg.JPG : https://imgur.com/XkXskiL ) , and the listing had it in the aplhabetical order :
Code:First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\Kill Stuff\Folder\*) is AForthThirdAfterwb.xlsx Use 1 in loop of unargumented Dir gives "c_xls_file.xls" Use 2 in loop of unargumented Dir gives "d_xlsm_file.xlsm" Use 3 in loop of unargumented Dir gives "SecondFirstAfterwb.xlsx" Use 4 in loop of unargumented Dir gives "Stack by change date .JPG" Use 5 in loop of unargumented Dir gives "ThirdSecondAfterwb.xlsx" Use 6 in loop of unargumented Dir gives ""
I use the last routine in the form to allow user selection of the folder to search for files
http://www.excelfox.com/forum/showth...ll=1#post11108. I looked at some arbritrary folders, - once again alphabetical order seems to come out:
Note that a file named as a number comes first in the list, as is consitant with Excel regarding text as "larger" than a number in sorting things http://www.eileenslounge.com/viewtop...=32154#p249178Code:Folder used is F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery wbSheetMakerClsdWbADOMsQueery First got by Dir(F:\Excel0202015Jan2016\ExcelForum\wbSheetMakerClsdWbADOMsQueery\*) is 83DB8900 Use 1 in loop of unargumented Dir gives "aaa.xlsm" Use 2 in loop of unargumented Dir gives "Amar321.xls.xlsx" Use 3 in loop of unargumented Dir gives "ApparantlyApparantIs_Change.JPG" Use 4 in loop of unargumented Dir gives "Aufzeichnen.JPG" Use 5 in loop of unargumented Dir gives "Book1.xls" Use 6 in loop of unargumented Dir gives "Book1.xlsm.zip" Use 7 in loop of unargumented Dir gives "CA930CD8.tmp" Use 8 in loop of unargumented Dir gives "ClosedWorkbook.xlsm" Use 9 in loop of unargumented Dir gives "CopyASheet.JPG" Use 10 in loop of unargumented Dir gives "CresssieFiles.JPG" Use 11 in loop of unargumented Dir gives "DB2IssJfürELProAbDec2014.xlsm" Use 12 in loop of unargumented Dir gives "EFFldr.xlsm" Use 13 in loop of unargumented Dir gives "EFldr1_1 Download.JPG" Use 14 in loop of unargumented Dir gives "Eileens Fldr.zip" Use 15 in loop of unargumented Dir gives "EileensFldr Contents Copy.JPG" Use 16 in loop of unargumented Dir gives "EileensFldr Contents Paste.JPG" Use 17 in loop of unargumented Dir gives "EileensFldr Make Empty Folder.JPG" Use 18 in loop of unargumented Dir gives "EileensFldr zip Download.JPG" Use 19 in loop of unargumented Dir gives "EileensFldr.zip" Use 20 in loop of unargumented Dir gives "EileensFolderExplainedOutput.JPG" Use 21 in loop of unargumented Dir gives "Example Folder and Macro File in same Folder.JPG" Use 22 in loop of unargumented Dir gives "FBandData.xlsm" Use 23 in loop of unargumented Dir gives "FBandDataNorie.xlsm" Use 24 in loop of unargumented Dir gives "FBandDataNorie.xlsx" Use 25 in loop of unargumented Dir gives "FormulaBarClosedWB.JPG" Use 26 in loop of unargumented Dir gives "GetData_ClosedBook+LINKS.xlsx" Use 27 in loop of unargumented Dir gives "GetData_ClosedBook.xls" Use 28 in loop of unargumented Dir gives "HimanshuktwCode.JPG" Use 29 in loop of unargumented Dir gives "KissMyClosedWB.JPG" Use 30 in loop of unargumented Dir gives "Mappe2.xlsm" Use 31 in loop of unargumented Dir gives "MazanDikCollectionWonk.xlsm" Use 32 in loop of unargumented Dir gives "mellowtangSummarySheets.xlsm" Use 33 in loop of unargumented Dir gives "MsQueerOptions.JPG" Use 34 in loop of unargumented Dir gives "myFileToClose.xlsm" Use 35 in loop of unargumented Dir gives "MyNewWorkbook.xlsx" Use 36 in loop of unargumented Dir gives "MySameFolder.JPG" Use 37 in loop of unargumented Dir gives "NeuProAktuelleMakros.xlsm" Use 38 in loop of unargumented Dir gives "NormalThisWorkbookCodeModule.JPG" Use 39 in loop of unargumented Dir gives "NutritionalValues2016.xlsx" Use 40 in loop of unargumented Dir gives "OnlyGets8810RowsInAQuerrListObjectTableThingyAnyways.JPG" Use 41 in loop of unargumented Dir gives "Plop.xlsm" Use 42 in loop of unargumented Dir gives "poo.xlsm" Use 43 in loop of unargumented Dir gives "RudyMSRAllSubFldrsFndRep.xlsm" Use 44 in loop of unargumented Dir gives "Sample.zip" Use 45 in loop of unargumented Dir gives "SchemaIniErrorPipe.JPG" Use 46 in loop of unargumented Dir gives "SrangeThisWorkbookCodeModule.JPG" Use 47 in loop of unargumented Dir gives "StopClosing.xlsm" Use 48 in loop of unargumented Dir gives "Summary sheet.xlsm" Use 49 in loop of unargumented Dir gives "template test.xlsm" Use 50 in loop of unargumented Dir gives "Top100MsQuery.JPG" Use 51 in loop of unargumented Dir gives "ViskasVerticalsMaster dataMjoza.xlsm" Use 52 in loop of unargumented Dir gives "wb2.csv" Use 53 in loop of unargumented Dir gives "wb2.xlsm" Use 54 in loop of unargumented Dir gives "wb2.xlsx" Use 55 in loop of unargumented Dir gives "WBAccessTimeTestData.xlsx" Use 56 in loop of unargumented Dir gives "WBAccestTimeTest.xlsm" Use 57 in loop of unargumented Dir gives "wbCodes.xlsb" Use 58 in loop of unargumented Dir gives "wbCodes.xlsm" Use 59 in loop of unargumented Dir gives "WBOpenRenameKlaredog.xls" Use 60 in loop of unargumented Dir gives "WBOpenRenameKlaredog.xlsm" Use 61 in loop of unargumented Dir gives "Wb_with_5Sheets_4Worksheets.xlsm" Use 62 in loop of unargumented Dir gives "WillyWonks.JPG" Use 63 in loop of unargumented Dir gives "workbook2.xlsm" Use 64 in loop of unargumented Dir gives "WorkbookOpenMsgBox.JPG" Use 65 in loop of unargumented Dir gives "WorksheetNames.JPG" Use 66 in loop of unargumented Dir gives "Worksheet_Change.JPG" Use 67 in loop of unargumented Dir gives ""
Up until now, all tests were done on an old Lap top using Vista operating system. I rechecked on a newer machine uisng Windows 7. I get the same results
"wbCodes.xlsm" : https://app.box.com/s/gfuintgifu1hgw5nap3jriz2x8mp911x ( Sub DirOrder() is here )
folder, "Folder" : https://app.box.com/s/vmmzeboetkt07ocggbx6p8lkurmp5wca
"wbCodes.xls" : https://app.box.com/s/gmdne53vehhuc6lvz3vfgyxqmwy07xlz ( Sub DirOrder() is here )




Reply With Quote
Bookmarks