首页 > 解决方案 > 下载C盘文件名到指定文件夹

问题描述

在此处输入图像描述

在上面的屏幕截图中,我从文件夹中提取了 C: 驱动器文件名,现在我想复制它们并将其移动到特定文件夹中。谁能告诉我如何做到这一点?

标签: excelvba

解决方案


Sub test()
    Set fso = CreateObject("scripting.filesystemobject")
    Dim rng As Range, cell As Range
    Set rng = Range("B2:B4") ' Replace with the range of your source file links
    For Each cell In rng
        fso.MoveFile Source:=cell.Value, Destination:="C:\dev\test\a\"  ' replace with destination folder as required.
    Next cell
End Sub


推荐阅读