|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 按钮1_Click()
Set fso = CreateObject("scripting.filesystemobject")
pth = ThisWorkbook.Path & "\提取工作簿名称+两个数据\"
r = 1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveSheet.UsedRange.Offset(1).ClearContents
arr = [a1].Resize(fso.getfolder(pth).Files.Count + 1, 3)
For Each f In fso.getfolder(pth).Files
If InStr(fso.getextensionname(f), "xls") > 0 Then
r = r + 1
arr(r, 1) = fso.getbasename(f)
With Workbooks.Open(f)
Set Rng = .Sheets(1).UsedRange.Find("HAWB#", lookat:=xlWhole)
If Not Rng Is Nothing Then arr(r, 2) = Rng.Offset(0, 1)
Set Rng = .Sheets(1).UsedRange.Find("No. of Pcs 件數", lookat:=xlWhole)
If Not Rng Is Nothing Then arr(r, 3) = Rng.Offset(1)
.Close False
End With
End If
Next
[a1].Resize(UBound(arr), UBound(arr, 2)) = arr
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|