|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test0()
- Dim ar, i As Long
- Dim strPath As String, strFile As String, strFolder As String
- strPath = ThisWorkbook.Path & "\"
- ar = Range("A1").CurrentRegion.Resize(, 4).Value
- With CreateObject("Scripting.FileSystemObject")
- For i = 3 To UBound(ar)
- strFolder = strPath & ar(i, 4) & "\"
- If Not .FolderExists(strFolder) Then .CreateFolder strFolder
- strFile = Dir(strPath & ar(i, 1) & ".*")
- While Len(strFile)
- If .FileExists(strFolder & strFile) Then .DeleteFile strFolder & strFile
- .MoveFile strPath & strFile, strFolder
- strFile = Dir
- Wend
- Next
- End With
- End Sub
复制代码 |
|