【问题标题】:MS Excel - auto-populate column with filenames from a specific folderMS Excel - 使用特定文件夹中的文件名自动填充列
【发布时间】:2016-10-22 20:09:47
【问题描述】:

我是非程序员,我需要一种自动方法来使用特定文件夹中的文件名填充 Excel 2016 中的列。我以前也从未构建过宏。有没有相对无痛的方法来做到这一点? 非常感谢。

【问题讨论】:

    标签: excel macros ms-office excel-2016 office-2016


    【解决方案1】:

    下面的代码将从 A 列中的 **C:\testFolder** 复制所有文件的名称。

    Sub test()
        Dim file As Variant
        file = Dir("C:\testFolder\")
        Range("A2").Activate
        While (file <> "")
            ActiveCell.Value = file
            ActiveCell.Offset(1, 0).Activate
            file = Dir
        Wend
    End Sub
    

    【讨论】:

    • 太棒了!完美运行。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-08-17
    • 2011-07-08
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-31
    相关资源
    最近更新 更多