【问题标题】:How to loop through multiple excel spreadsheet in order to sort every spreadsheet?如何遍历多个 Excel 电子表格以便对每个电子表格进行排序?
【发布时间】:2017-07-30 15:15:29
【问题描述】:

我认为我的问题很简单,但我不知道如何处理它。我会尽量做到准确,并向您展示我已经尝试过的内容以及无效的内容。

我想对多个电子表格进行排序。

我正在分析股票市场价格。每个电子表格都有相同的架构,看起来像这样(简化):

Date          OpenPrice             ClosePrice               Volume
30.07.2017    12                    13                       500
28.07.2017    13                    14                       650
25.07.2017    14                    11                       1200

等等……

我需要从过去到未来对每个电子表格进行倒序排序。应该是这样的:

Date          OpenPrice             ClosePrice               Volume
25.07.2017    14                    11                       1200
28.07.2017    13                    14                       650
30.07.2017    12                    13                       500

我可以轻松地对电子表格进行排序,使用 Excel 排序工具(我正在对日期进行排序,因此可以按字母顺序排序)或使用带有循环的 VBA 脚本,如 splitcolumnsplitrow

我的问题是我无法一次对所有电子表格 (500+) 进行排序。 VBA 脚本或 excel 工具仅对一个电子表格进行排序,我必须手动重复该操作。

【问题讨论】:

  • 查找 For each worksheet in thisworkbook.sheets 循环以附加到您已有的 VBA 代码?

标签: excel sorting vba


【解决方案1】:
Dim Current as Worksheet
For each Current in Worksheets

    ...Do the sort here. If you need to refer to sheet you are sorting, use Current

Next

【讨论】:

    猜你喜欢
    • 2020-03-14
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多