|
- Sub bcfz()
- Dim i&, Myr&, Arr
- Dim d, d1, d2, d3, k, str, Mypath
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set d2 = CreateObject("Scripting.Dictionary")
- Set d3 = CreateObject("Scripting.Dictionary")
- Myr = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
- Arr = Sheets("Sheet1").Range("a2:c" & Myr)
- Mypath = ThisWorkbook.Path
- For i = 1 To UBound(Arr)
- d(Arr(i, 2)) = ""
- d1(Arr(i, 1)) = Arr(i, 2)
- d2(Arr(i, 1)) = Arr(i, 3)
- Next
- k = d.keys
- MkDir (Mypath & "\结果") '新建文件夹
- For i = 0 To d.Count - 1
- MkDir (Mypath & "\结果" & "" & k(i)) '新建二级文件夹
- Next
- s = Dir(Mypath & "\出租土地" & "*.xls")
- Do While s <> ""
- str = Left(s, 15)
- If Not d3.exists(d1(str) & "" & d2(str)) Then
- d3(d1(str) & "" & d2(str)) = ""
- MkDir (Mypath & "\结果" & d1(str) & "" & d2(str))
- End If
- Set fs = CreateObject("Scripting.FileSystemObject")
- fs.movefile Mypath & "\出租土地" & s, Mypath & "\结果" & d1(str) & "" & d2(str) & ""
- s = Dir
- Loop
- Set d = Nothing
- Set d1 = Nothing
- Set d2 = Nothing
- Set d3 = Nothing
- End Sub
复制代码 |
|