vba Dir 函数中的特定顺序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20472205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 00:52:25  来源:igfitidea点击:

Dir Function in a specific order?

excelvbaexcel-vba

提问by

I am using VBA, and looping through spreadsheets in a specific folder - opening the spreadsheets, coping some lines then pasting it into a master spreadsheet. I made use of the following link to achieve the loop:

我正在使用 VBA,并循环浏览特定文件夹中的电子表格 - 打开电子表格,处理一些行,然后将其粘贴到主电子表格中。我利用以下链接来实现循环:

Loop through files in a folder using VBA?

使用 VBA 遍历文件夹中的文件?

My problem/question: the spreadsheets have the date saved as the file name - for example:

我的问题/问题:电子表格将日期保存为文件名 - 例如:

Trader Estimate T+1 Consol_20131003.xlsx

交易员预估 T+1 Consol_20131003.xlsx

But it seems using the Dir function, that the spreadsheets are not being opened in the chronological order as dictated by the date in the filename.

但似乎使用 Dir 函数,电子表格没有按照文件名中的日期指示的时间顺序打开。

How would I achieve this opening in chronological order (according to the filename)?

我将如何按时间顺序(根据文件名)实现这个开放?

Don't know if this makes a difference but the spreadsheets are not saved on this computer in chronological order - ie. if I order the folder of spreadsheets by date modified, they are not in perfect order as dictated by the date in their filename.

不知道这是否有区别,但电子表格并未按时间顺序保存在这台计算机上 - 即。如果我按修改日期对电子表格文件夹进行排序,则它们的顺序并不完全符合文件名中的日期。

Any help is very much appreciated

很感谢任何形式的帮助

回答by Youbaraj Sharma

My be you will find these links helpful to get started

我是你会发现这些链接有助于开始

QuickSort(Get a sorted list of files in a directory using Dir and Quicksort)

QuickSort(使用 Dir 和 Quicksort 获取目录中文件的排序列表)

Similar Question here

类似的问题 在这里