|
哪位大神帮忙修改成批量生成XLS文件
Sub 批量新建文件夹()
Dim i As Integer '用于下方数组
Dim Arr1(), Arr2() '定义一个数组,不能定义大小和类型
Dim Fso, Fld '定义文件路径
Dim rowmax '找到数据的行数
start_time = Timer '计时开始
'数据的行数
rowmax = [A1048576].End(xlUp).Row
'把两列数据分别赋值给两个个数组
Arr1 = Range("A2:A" & rowmax)
Arr2 = Range("B2:B" & rowmax)
'选择建文件夹的路径
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fld = Fso.getfolder(CreateObject("Shell.Application").BrowseForFolder(0, "请选择需要创建文件夹的根目录", 0, "").Self.Path & "")
'开始批量新建文件夹
For i = 1 To UBound(Arr1)
folderName = Arr1(i, 1) & " " & Arr2(i, 1)
If Dir(Fld & "\" & folderName, vbDirectory) = vbNullString Then '如果文件夹不存在,则新建
VBA.MkDir (Fld & "\" & folderName)
End If
Next
'建好了
MsgBox "OK"
cost_time = Timer - start_time '计时结束,计算用时
Range("C1") = cost_time
End Sub
|
|