|
偶也来凑热闹
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim 路径, 文件夹, 表名, 行
Dim fos, fld
路径 = ThisWorkbook.Path
Dim uu As FileDialog
Set uu = Application.FileDialog(msoFileDialogFolderPicker)
With uu
.Title = "选择制作单文件夹"
.InitialFileName = 路径 & "\"
If .Show = 0 Then End
End With
文件夹 = uu.SelectedItems(1)
With ThisWorkbook.Sheets("sheet1")
行 = .Cells(Rows.Count, 1).End(xlUp).Row + 1
Set fso = New filesystemobject
Set fld = fso.GetFolder(文件夹)
For Each fil In fld.Files
表名 = fil.Name
Workbooks.Open 文件夹 & "\" & 表名
.Cells(行, 1) = Left(表名, Len(表名) - 4)
.Cells(行, 2) = Workbooks(表名).Sheets("sheet1").Range("e22")
Cells(行, 1).Resize(1, 2).Borders.LineStyle = xlContinuous
行 = 行 + 1
Workbooks(表名).Close
Next
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
|
|