|
Sub 新建文件夹()
Dim fso
myPath = ThisWorkbook.Path & "\"
Set fso = CreateObject("Scripting.FileSystemObject")
With ActiveSheet
r = .Cells(Rows.Count, 2).End(xlUp).Row
If r < 2 Then MsgBox "数据源为空!": End
ar = .Range("b1:c" & r)
End With
For i = 2 To UBound(ar)
If ar(i, 1) <> "" And ar(i, 2) <> "" Then
If IsDate(ar(i, 1)) Then
nf = Year(ar(i, 1))
yf = Month(ar(i, 1)) & "月委托单"
nfwjj = myPath & nf
If Not fso.folderexists(nfwjj) Then fso.CreateFolder nfwjj
yfwjj = myPath & nf & "\" & yf
If Not fso.folderexists(yfwjj) Then fso.CreateFolder yfwjj
bhwjj = myPath & nf & "\" & yf & "\" & ar(i, 2)
If Not fso.folderexists(bhwjj) Then fso.CreateFolder bhwjj
End If
End If
Next i
Set fso = Nothing
MsgBox "ok!"
End Sub
|
|